on master help sign in
Add a check to prevent re-selecting same range (#2760)
commit3bd554557782ff4c3c5d2f686f01c4a84aab6e41 authorRyang Sohn <loop.infinitely@gmail.com> dateTue 14 Jun 2022, 22:37 (4 years ago) parentd7bd441
1 file changed+7−4
helix-term/src/commands.rs+7−4
helix-term/src/commands.rs+7−4
@@ -3770,12 +3770,15 @@ fn expand_selection(cx: &mut Context) {
37703770 let text = doc.text().slice(..);
37713771
37723772 let current_selection = doc.selection(view.id);
3773+ let selection = object::expand_selection(syntax, text, current_selection.clone());
37733774
3774− // save current selection so it can be restored using shrink_selection
3775− view.object_selections.push(current_selection.clone());
3775+ // check if selection is different from the last one
3776+ if *current_selection != selection {
3777+ // save current selection so it can be restored using shrink_selection
3778+ view.object_selections.push(current_selection.clone());
37763779
3777− let selection = object::expand_selection(syntax, text, current_selection.clone());
3778− doc.set_selection(view.id, selection);
3780+ doc.set_selection(view.id, selection);
3781+ }
37793782 }
37803783 };
37813784 motion(cx.editor);