Skip to content

Commit

Permalink
Add a check to prevent re-selecting same range (#2760)
Browse files Browse the repository at this point in the history
  • Loading branch information
sohnryang authored Jun 14, 2022
1 parent d7bd441 commit 3bd5545
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3bd5545

Please sign in to comment.