aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorIvan Tham2021-10-29 01:08:53 +0000
committerGitHub2021-10-29 01:08:53 +0000
commitbc6a34d97edae55811c2476278a6288d7d258af3 (patch)
tree348acba335570d6a477b2347238cfcc8bbb98660 /helix-term
parent21d535565bfcc5ff4e2eae34329b051944a8d1f5 (diff)
Make match work with extend and multi cursors (#920)
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/commands.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 9eda2c23..28657865 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -4386,14 +4386,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);
}
}