vim: Fix matching brackets with 1 offset in normal mode (#17396)

jjy and Conrad Irwin created

Closes #17342

Release Notes:

- N/A

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>

Change summary

crates/editor/src/highlight_matching_bracket.rs | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

Detailed changes

crates/editor/src/highlight_matching_bracket.rs 🔗

@@ -1,4 +1,5 @@
 use gpui::ViewContext;
+use language::CursorShape;
 
 use crate::{Editor, RangeToAnchorExt};
 
@@ -13,11 +14,18 @@ pub fn refresh_matching_bracket_highlights(editor: &mut Editor, cx: &mut ViewCon
         return;
     }
 
-    let head = newest_selection.head();
     let snapshot = editor.snapshot(cx);
+    let head = newest_selection.head();
+    let mut tail = head;
+    if (editor.cursor_shape == CursorShape::Block || editor.cursor_shape == CursorShape::Hollow)
+        && head < snapshot.buffer_snapshot.len()
+    {
+        tail += 1;
+    }
+
     if let Some((opening_range, closing_range)) = snapshot
         .buffer_snapshot
-        .innermost_enclosing_bracket_ranges(head..head, None)
+        .innermost_enclosing_bracket_ranges(head..tail, None)
     {
         editor.highlight_background::<MatchingBracketHighlight>(
             &[