mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-28 20:01:33 +00:00
Merge pull request #886 from zed-industries/fix-delete-to-beginning-of-line
Delete selected text when deleting to beginning of line, regardless of selection direction
This commit is contained in:
commit
1dcaec7fb4
2 changed files with 20 additions and 0 deletions
|
@ -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",
|
||||
|
|
|
@ -3791,6 +3791,10 @@ impl Editor {
|
|||
cx: &mut ViewContext<Self>,
|
||||
) {
|
||||
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));
|
||||
|
|
Loading…
Reference in a new issue