From 6e71c43d2970ad1a8944992677d0597a0ee8feaa Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 6 Sep 2021 13:17:44 +0200 Subject: [PATCH] Delete `Editor::newline` and just use the `Insert` action --- zed/src/editor.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/zed/src/editor.rs b/zed/src/editor.rs index 6176b402c5..63ebe9982f 100644 --- a/zed/src/editor.rs +++ b/zed/src/editor.rs @@ -46,7 +46,6 @@ const MAX_LINE_LEN: usize = 1024; action!(Cancel); action!(Backspace); action!(Delete); -action!(Newline); action!(Insert, String); action!(DeleteLine); action!(DeleteToPreviousWordBoundary); @@ -105,8 +104,12 @@ pub fn init(cx: &mut MutableAppContext) { Binding::new("ctrl-h", Backspace, Some("Editor")), Binding::new("delete", Delete, Some("Editor")), Binding::new("ctrl-d", Delete, Some("Editor")), - Binding::new("enter", Newline, Some("Editor && mode == full")), - Binding::new("alt-enter", Newline, Some("Editor && mode == auto_height")), + Binding::new("enter", Insert("\n".into()), Some("Editor && mode == full")), + Binding::new( + "alt-enter", + Insert("\n".into()), + Some("Editor && mode == auto_height"), + ), Binding::new("tab", Insert("\t".into()), Some("Editor")), Binding::new("ctrl-shift-K", DeleteLine, Some("Editor")), Binding::new( @@ -199,7 +202,6 @@ pub fn init(cx: &mut MutableAppContext) { cx.add_action(Editor::select); cx.add_action(Editor::cancel); cx.add_action(Editor::insert); - cx.add_action(Editor::newline); cx.add_action(Editor::backspace); cx.add_action(Editor::delete); cx.add_action(Editor::delete_line); @@ -752,10 +754,6 @@ impl Editor { self.end_transaction(cx); } - fn newline(&mut self, _: &Newline, cx: &mut ViewContext) { - self.insert(&Insert("\n".into()), cx); - } - pub fn backspace(&mut self, _: &Backspace, cx: &mut ViewContext) { self.start_transaction(cx); let mut selections = self.selections(cx.as_ref()).to_vec();