Skip to content

Commit

Permalink
don't save change history in insert mode
Browse files Browse the repository at this point in the history
  • Loading branch information
QiBaobin committed Nov 10, 2021
1 parent 6871d5b commit cb47f94
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -3861,7 +3867,7 @@ pub mod insert {
.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)
}
}

Expand Down

0 comments on commit cb47f94

Please sign in to comment.