From ef591a1abf9db602f7c3f76aeec8bbe331ee80f7 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 20 Sep 2023 17:21:10 -0700 Subject: [PATCH] Fix select all bugs (#3001) Release Notes: - Restore `cmd-shift-d` as 'editor::DuplicateLine' and move `editor::SelectAllMatches` to `cmd-shift-L`, like in VS Code. The previous action for `cmd-shift-l`, `editor::SplitSelectionIntoLines`, has been moved to the sublime base keymap. - Fixes a panic when using 'editor::SelectAllMatches' on an empty line. --- assets/keymaps/default.json | 4 ++-- assets/keymaps/sublime_text.json | 1 + crates/editor/src/editor.rs | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/assets/keymaps/default.json b/assets/keymaps/default.json index 8d8f762b8dbb3af718841a0d7e25d1fdf790da3b..8fbe87de2bf76f6dbf09febc9145d8db3676c677 100644 --- a/assets/keymaps/default.json +++ b/assets/keymaps/default.json @@ -303,7 +303,7 @@ "replace_newest": false } ], - "cmd-shift-d": "editor::SelectAllMatches", + "cmd-shift-l": "editor::SelectAllMatches", "ctrl-cmd-d": [ "editor::SelectPrevious", { @@ -463,7 +463,7 @@ "context": "Editor", "bindings": { "ctrl-shift-k": "editor::DeleteLine", - "cmd-shift-l": "editor::SplitSelectionIntoLines", + "cmd-shift-d": "editor::DuplicateLine", "ctrl-j": "editor::JoinLines", "ctrl-cmd-up": "editor::MoveLineUp", "ctrl-cmd-down": "editor::MoveLineDown", diff --git a/assets/keymaps/sublime_text.json b/assets/keymaps/sublime_text.json index a70a61af5519f5ecb9ea161d650ccb96f4b99909..dc1fc1c3ef0286b42b67937ecade7905ef233270 100644 --- a/assets/keymaps/sublime_text.json +++ b/assets/keymaps/sublime_text.json @@ -17,6 +17,7 @@ "ctrl-shift-down": "editor::AddSelectionBelow", "cmd-shift-space": "editor::SelectAll", "ctrl-shift-m": "editor::SelectLargerSyntaxNode", + "cmd-shift-l": "editor::SplitSelectionIntoLines", "cmd-shift-a": "editor::SelectLargerSyntaxNode", "shift-f12": "editor::FindAllReferences", "alt-cmd-down": "editor::GoToDefinition", diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 29782eb1f35949b51ecd9d3d9bead041634ac3b4..0827e1326402e39bfeeab389ad7a9df6d8eb5587 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -6048,10 +6048,12 @@ impl Editor { let query = buffer .text_for_range(selection.start..selection.end) .collect::(); + + let is_empty = query.is_empty(); let select_state = SelectNextState { query: AhoCorasick::new(&[query])?, wordwise: true, - done: false, + done: is_empty, }; select_next_match_ranges( self,