diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 7d2cd67e2..c9a4ea2d4 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -569,12 +569,12 @@ fn extend_to_line_start(cx: &mut Context) { fn kill_to_line_start(cx: &mut Context) { extend_to_line_start(cx); - delete_selection(cx); + delete_selection_and_append_history(cx, false); } fn kill_to_line_end(cx: &mut Context) { extend_to_line_end(cx); - delete_selection(cx); + delete_selection_and_append_history(cx, false); } fn goto_first_nonwhitespace(cx: &mut Context) { @@ -1560,13 +1560,19 @@ fn delete_selection_impl(reg: &mut Register, doc: &mut Document, view_id: ViewId } fn delete_selection(cx: &mut Context) { + delete_selection_and_append_history(cx, true); +} + +fn delete_selection_and_append_history(cx: &mut Context, append_change_to_history: bool) { let reg_name = cx.register.unwrap_or('"'); let (view, doc) = current!(cx.editor); let registers = &mut cx.editor.registers; let reg = registers.get_mut(reg_name); delete_selection_impl(reg, doc, view.id); - doc.append_changes_to_history(view.id); + if append_change_to_history { + doc.append_changes_to_history(view.id); + } // exit select mode, if currently in select mode exit_select_mode(cx); @@ -3861,7 +3867,7 @@ pub fn delete_word_forward(cx: &mut Context) { .clone() .transform(|range| movement::move_next_word_start(text, range, count)); doc.set_selection(view.id, selection); - delete_selection(cx) + delete_selection_and_append_history(cx, false) } }