Skip to content

Commit

Permalink
Make match work with extend and multi cursors
Browse files Browse the repository at this point in the history
  • Loading branch information
pickfire committed Oct 28, 2021
1 parent 58b8100 commit b61ee50
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4361,14 +4361,15 @@ fn match_brackets(cx: &mut Context) {
let (view, doc) = current!(cx.editor);

if let Some(syntax) = doc.syntax() {
let pos = doc
.selection(view.id)
.primary()
.cursor(doc.text().slice(..));
if let Some(pos) = match_brackets::find(syntax, doc.text(), pos) {
let selection = Selection::point(pos);
doc.set_selection(view.id, selection);
};
let text = doc.text().slice(..);
let selection = doc.selection(view.id).clone().transform(|range| {
if let Some(pos) = match_brackets::find(syntax, doc.text(), range.anchor) {
range.put_cursor(text, pos, doc.mode == Mode::Select)
} else {
range
}
});
doc.set_selection(view.id, selection);
}
}

Expand Down

0 comments on commit b61ee50

Please sign in to comment.