on master help sign in
Make match work with extend and multi cursors (#920)
commitbc6a34d97edae55811c2476278a6288d7d258af3 authorIvan Tham <pickfire@riseup.net> dateFri 29 Oct 2021, 09:08 (5 years ago) parent21d5355
1 file changed+9−8
helix-term/src/commands.rs+9−8
helix-term/src/commands.rs+9−8
@@ -4386,14 +4386,15 @@ fn match_brackets(cx: &mut Context) {
43864386 let (view, doc) = current!(cx.editor);
43874387
43884388 if let Some(syntax) = doc.syntax() {
4389− let pos = doc
4390− .selection(view.id)
4391− .primary()
4392− .cursor(doc.text().slice(..));
4393− if let Some(pos) = match_brackets::find(syntax, doc.text(), pos) {
4394− let selection = Selection::point(pos);
4395− doc.set_selection(view.id, selection);
4396− };
4389+ let text = doc.text().slice(..);
4390+ let selection = doc.selection(view.id).clone().transform(|range| {
4391+ if let Some(pos) = match_brackets::find(syntax, doc.text(), range.anchor) {
4392+ range.put_cursor(text, pos, doc.mode == Mode::Select)
4393+ } else {
4394+ range
4395+ }
4396+ });
4397+ doc.set_selection(view.id, selection);
43974398 }
43984399}
43994400