Add a check to prevent re-selecting same range (#2760)

This commit is contained in:
Ryang Sohn 2022-06-14 22:37:40 +09:00 committed by GitHub
parent d7bd441675
commit 3bd5545577
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3770,12 +3770,15 @@ fn expand_selection(cx: &mut Context) {
let text = doc.text().slice(..);
let current_selection = doc.selection(view.id);
// 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);
// 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());
doc.set_selection(view.id, selection);
}
}
};
motion(cx.editor);