Skip to content

Commit

Permalink
fix x and X command
Browse files Browse the repository at this point in the history
  • Loading branch information
nakagami committed Aug 24, 2024
1 parent 17bf56d commit 18b865d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pyvim/key_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 18b865d

Please sign in to comment.