From c90ae3d90a16a804e890a166cce30788b650a631 Mon Sep 17 00:00:00 2001 From: jjy Date: Sat, 7 Sep 2024 04:06:30 +0800 Subject: [PATCH] vim: Fix matching brackets with 1 offset in normal mode (#17396) Closes #17342 Release Notes: - N/A --------- Co-authored-by: Conrad Irwin --- crates/editor/src/highlight_matching_bracket.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/editor/src/highlight_matching_bracket.rs b/crates/editor/src/highlight_matching_bracket.rs index 525d70f747..5ddda65692 100644 --- a/crates/editor/src/highlight_matching_bracket.rs +++ b/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::( &[