From 30f2604a8d692982714c5caea1d2b1dabcb6a1a5 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 21 Apr 2022 14:25:31 -0600 Subject: [PATCH 1/2] Map shift-backspace to backspace A user pointed out that it was weird that this didn't work and violated their muscle memory. --- assets/keymaps/default.json | 1 + 1 file changed, 1 insertion(+) diff --git a/assets/keymaps/default.json b/assets/keymaps/default.json index 43c1f84e2a..28e5ed574c 100644 --- a/assets/keymaps/default.json +++ b/assets/keymaps/default.json @@ -26,6 +26,7 @@ "bindings": { "escape": "editor::Cancel", "backspace": "editor::Backspace", + "shift-backspace": "editor::Backspace", "ctrl-h": "editor::Backspace", "delete": "editor::Delete", "ctrl-d": "editor::Delete", From 8ec2b5e359d7b8f8baeada40fb4cdbbc8ad95fa2 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 21 Apr 2022 15:12:18 -0600 Subject: [PATCH 2/2] Delete selected text when deleting to beginning of line --- crates/editor/src/editor.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 97be28ebd4..1df5856843 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -3791,6 +3791,10 @@ impl Editor { cx: &mut ViewContext, ) { self.transact(cx, |this, cx| { + this.move_selections(cx, |_, selection| { + selection.reversed = true; + }); + this.select_to_beginning_of_line( &SelectToBeginningOfLine { stop_at_soft_wraps: false, @@ -7430,6 +7434,21 @@ mod tests { }); } + #[gpui::test] + fn test_delete_to_beginning_of_line(cx: &mut gpui::MutableAppContext) { + cx.set_global(Settings::test(cx)); + let (text, ranges) = marked_text_ranges("one [two three] four"); + let buffer = MultiBuffer::build_simple(&text, cx); + + let (_, editor) = cx.add_window(Default::default(), |cx| build_editor(buffer.clone(), cx)); + + editor.update(cx, |editor, cx| { + editor.select_ranges(ranges, None, cx); + editor.delete_to_beginning_of_line(&DeleteToBeginningOfLine, cx); + assert_eq!(editor.text(cx), " four"); + }); + } + #[gpui::test] fn test_delete_to_word_boundary(cx: &mut gpui::MutableAppContext) { cx.set_global(Settings::test(cx));