Delete Editor::newline and just use the Insert action

This commit is contained in:
Antonio Scandurra 2021-09-06 13:17:44 +02:00
parent 2aadc97126
commit 6e71c43d29

View File

@ -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>) {
self.insert(&Insert("\n".into()), cx);
}
pub fn backspace(&mut self, _: &Backspace, cx: &mut ViewContext<Self>) {
self.start_transaction(cx);
let mut selections = self.selections(cx.as_ref()).to_vec();