on master help sign in
Add a check to prevent re-selecting same range (#2760)
3bd5545Ryang Sohn
helix-term/src/commands.rs+7−4
@@ -3770,12 +3770,15 @@ fn expand_selection(cx: &mut Context) {
3770 let text = doc.text().slice(..);
3770 let text = doc.text().slice(..);
3771
3771
3772 let current_selection = doc.selection(view.id);
3772 let current_selection = doc.selection(view.id);
3773+ let selection = object::expand_selection(syntax, text, current_selection.clone());
3773
3774
3775+ // check if selection is different from the last one
3776+ if *current_selection != selection {
3774− // save current selection so it can be restored using shrink_selection
3777+ // save current selection so it can be restored using shrink_selection
3775− view.object_selections.push(current_selection.clone());
3778+ view.object_selections.push(current_selection.clone());
3776
3779
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+ }
3779 }
3782 }
3780 };
3783 };
3781 motion(cx.editor);
3784 motion(cx.editor);