diff --git a/pyvim/key_bindings.py b/pyvim/key_bindings.py index 4dee080..395847e 100644 --- a/pyvim/key_bindings.py +++ b/pyvim/key_bindings.py @@ -341,23 +341,24 @@ def _delete(event: E) -> None: """ Delete character. """ - editor.start_edit_command() - - buff = event.current_buffer - count = min(event.arg, len(buff.document.current_line_after_cursor)) + buffer = event.current_buffer + count = min(event.arg, len(buffer.document.current_line_after_cursor)) if count: + editor.start_edit_command(event) text = event.current_buffer.delete(count=count) event.app.clipboard.set_text(text) + editor.finish_edit_command() @kb.add("X", filter=vi_navigation_mode) def _delete_before_cursor(event: E) -> None: - editor.start_edit_command() - buff = event.current_buffer - count = min(event.arg, len(buff.document.current_line_before_cursor)) + buffer = event.current_buffer + count = min(event.arg, len(buffer.document.current_line_before_cursor)) if count: + editor.start_edit_command(event) text = event.current_buffer.delete_before_cursor(count=count) event.app.clipboard.set_text(text) + editor.finish_edit_command() @kb.add(">", ">", filter=vi_navigation_mode) @kb.add("c-t", filter=vi_insert_mode)