aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorRyang Sohn2022-06-14 13:37:40 +0000
committerGitHub2022-06-14 13:37:40 +0000
commit3bd554557782ff4c3c5d2f686f01c4a84aab6e41 (patch)
treeedea2e0737214fdc758ee6de20212ff314da65f7 /helix-term
parentd7bd4416754fb4e3051c3ceedd5fd525b0361ef8 (diff)
Add a check to prevent re-selecting same range (#2760)
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/commands.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 628fd8fb..c9c8e6a9 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -3770,12 +3770,15 @@ fn expand_selection(cx: &mut Context) {
let text = doc.text().slice(..);
let current_selection = doc.selection(view.id);
+ let selection = object::expand_selection(syntax, text, current_selection.clone());
- // save current selection so it can be restored using shrink_selection
- view.object_selections.push(current_selection.clone());
+ // check if selection is different from the last one
+ if *current_selection != selection {
+ // save current selection so it can be restored using shrink_selection
+ view.object_selections.push(current_selection.clone());
- let selection = object::expand_selection(syntax, text, current_selection.clone());
- doc.set_selection(view.id, selection);
+ doc.set_selection(view.id, selection);
+ }
}
};
motion(cx.editor);