mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-11 21:13:02 +00:00
Delete selected text when deleting to beginning of line
This commit is contained in:
parent
30f2604a8d
commit
8ec2b5e359
1 changed files with 19 additions and 0 deletions
|
@ -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