diff --git a/assets/keymaps/default.json b/assets/keymaps/default.json index 43c1f84e2abf1a3dee819ad01555f1aa4115c75d..28e5ed574c71270feb56787d90eb6a198fed9816 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", diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 97be28ebd420163a96a100073fd1a1a46c8e0df1..1df5856843c88ef69003d731647a5d0c4a9c4b2b 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));