on master help sign in
Revert "Improve dedent behavior, make kill_to_line_end behave like emacs (#1173)"
c955eaaBlaž Hrastnik
helix-term/src/commands.rs+4−15
@@ -173,10 +173,6 @@ impl Command {
173 self.doc
173 self.doc
174 }
174 }
175
175
176− pub fn fun(&self) -> fn(&mut Context) {
177− self.fun
178− }
179−
180 #[rustfmt::skip]
176 #[rustfmt::skip]
181 commands!(
177 commands!(
182 no_op, "Do nothing",
178 no_op, "Do nothing",
@@ -607,15 +603,8 @@ fn kill_to_line_end(cx: &mut Context) {
607
603
608 let selection = doc.selection(view.id).clone().transform(|range| {
604 let selection = doc.selection(view.id).clone().transform(|range| {
609 let line = range.cursor_line(text);
605 let line = range.cursor_line(text);
610− let line_end_pos = line_end_char_index(&text, line);
606+ let pos = line_end_char_index(&text, line);
611− let pos = range.cursor(text);
612−
613− let mut new_range = range.put_cursor(text, line_end_pos, true);
607+ range.put_cursor(text, pos, true)
614− // don't want to remove the line separator itself if the cursor doesn't reach the end of line.
615− if pos != line_end_pos {
616− new_range.head = line_end_pos;
617− }
618− new_range
619 });
608 });
620 delete_selection_insert_mode(doc, view, &selection);
609 delete_selection_insert_mode(doc, view, &selection);
621}
610}
@@ -3512,12 +3501,12 @@ fn open(cx: &mut Context, open: Open) {
3512}
3501}
3513
3502
3514// o inserts a new line after each line with a selection
3503// o inserts a new line after each line with a selection
3515−pub(crate) fn open_below(cx: &mut Context) {
3504+fn open_below(cx: &mut Context) {
3516 open(cx, Open::Below)
3505 open(cx, Open::Below)
3517}
3506}
3518
3507
3519// O inserts a new line before each line with a selection
3508// O inserts a new line before each line with a selection
3520−pub(crate) fn open_above(cx: &mut Context) {
3509+fn open_above(cx: &mut Context) {
3521 open(cx, Open::Above)
3510 open(cx, Open::Above)
3522}
3511}
3523
3512
helix-term/src/ui/editor.rs−13
@@ -1026,19 +1026,6 @@ impl Component for EditorView {
1026 (Mode::Insert, Mode::Normal) => {
1026 (Mode::Insert, Mode::Normal) => {
1027 // if exiting insert mode, remove completion
1027 // if exiting insert mode, remove completion
1028 self.completion = None;
1028 self.completion = None;
1029−
1030− let last_cmd = self.last_insert.0.fun();
1031− const OPEN_BELOW_FUN: fn(&mut commands::Context) = commands::open_below;
1032− const OPEN_ABOVE_FUN: fn(&mut commands::Context) = commands::open_above;
1033− // For user friendly,
1034− // Remove whitespaces if we go from insert mode(through open below/above) to normal mode without any keys in between.
1035− // Example: `o<esc>`.
1036− if matches!(last_cmd, OPEN_BELOW_FUN | OPEN_ABOVE_FUN)
1037− && self.last_insert.1.len() == 1
1038− {
1039− commands::Command::goto_line_start.execute(&mut cxt);
1040− commands::Command::kill_to_line_end.execute(&mut cxt);
1041− }
1042 }
1029 }
1043 _ => (),
1030 _ => (),
1044 }
1031 }