Skip to content

Commit

Permalink
fix match bracket matching (#10777)
Browse files Browse the repository at this point in the history
  • Loading branch information
krish-r authored May 16, 2024
1 parent 889bbef commit 2301430
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions helix-core/src/match_brackets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ fn find_pair(
(as_char(doc, &open), as_char(doc, &close))
{
if PAIRS.contains(&(open, close)) {
if start_pos == pos_ {
if end_pos == pos_ {
return Some(start_pos);
}

// We return the end char if the cursor is either on the start char
// or at some arbitrary position between start and end char.
if traverse_parents || end_pos == pos_ {
if traverse_parents || start_pos == pos_ {
return Some(end_pos);
}
}
Expand Down
16 changes: 16 additions & 0 deletions helix-term/tests/test/commands/movement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,22 @@ async fn match_bracket() -> anyhow::Result<()> {
}
"##},
),
// named node with 2 or more children
(
indoc! {r##"
use a::#[{|]#
b::{c, d, e, f, g},
h, i, j, k, l, m, n,
};
"##},
"mm",
indoc! {r##"
use a::{
b::{c, d, e, f, g},
h, i, j, k, l, m, n,
#[}|]#;
"##},
),
];

let python_tests = vec![
Expand Down

0 comments on commit 2301430

Please sign in to comment.