on master help sign in
Make match work with extend and multi cursors (#920)
bc6a34dIvan Tham
helix-term/src/commands.rs+9−8
@@ -4386,14 +4386,15 @@ fn match_brackets(cx: &mut Context) {
4386 let (view, doc) = current!(cx.editor);
4386 let (view, doc) = current!(cx.editor);
4387
4387
4388 if let Some(syntax) = doc.syntax() {
4388 if let Some(syntax) = doc.syntax() {
4389− let pos = doc
4390− .selection(view.id)
4391− .primary()
4392− .cursor(doc.text().slice(..));
4389+ let text = doc.text().slice(..);
4390+ let selection = doc.selection(view.id).clone().transform(|range| {
4393− if let Some(pos) = match_brackets::find(syntax, doc.text(), pos) {
4391+ if let Some(pos) = match_brackets::find(syntax, doc.text(), range.anchor) {
4394− let selection = Selection::point(pos);
4392+ range.put_cursor(text, pos, doc.mode == Mode::Select)
4393+ } else {
4394+ range
4395+ }
4396+ });
4395− doc.set_selection(view.id, selection);
4397+ doc.set_selection(view.id, selection);
4396− };
4397 }
4398 }
4398}
4399}
4399
4400