Skip to content

Commit 60b22db

Browse files
Reset recording attributes in ViState in ViState.reset.
1 parent 3ccd880 commit 60b22db

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

prompt_toolkit/key_binding/bindings/vi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ def _(event):
338338
if vi_state.input_mode in (InputMode.INSERT, InputMode.REPLACE):
339339
buffer.cursor_position += buffer.document.get_cursor_left_position()
340340

341-
vi_state.reset(InputMode.NAVIGATION)
341+
vi_state.input_mode = InputMode.NAVIGATION
342342

343343
if bool(buffer.selection_state):
344344
buffer.exit_selection()

prompt_toolkit/key_binding/vi_state.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def __init__(self):
4040
self.named_registers = {}
4141

4242
#: The Vi mode we're currently in to.
43-
self.input_mode = InputMode.INSERT
43+
self.__input_mode = InputMode.INSERT
4444

4545
#: Waiting for digraph.
4646
self.waiting_for_digraph = False
@@ -57,13 +57,32 @@ def __init__(self):
5757
self.recording_register = None
5858
self.current_recording = ''
5959

60-
def reset(self, mode=InputMode.INSERT):
60+
@property
61+
def input_mode(self):
62+
" Get `InputMode`. "
63+
return self.__input_mode
64+
65+
@input_mode.setter
66+
def input_mode(self, value):
67+
" Set `InputMode`. "
68+
if value == InputMode.NAVIGATION:
69+
self.waiting_for_digraph = False
70+
self.operator_func = None
71+
self.operator_arg = None
72+
73+
self.__input_mode = value
74+
75+
def reset(self):
6176
"""
6277
Reset state, go back to the given mode. INSERT by default.
6378
"""
6479
# Go back to insert mode.
65-
self.input_mode = mode
80+
self.input_mode = InputMode.INSERT
6681

6782
self.waiting_for_digraph = False
6883
self.operator_func = None
6984
self.operator_arg = None
85+
86+
# Reset recording state.
87+
self.recording_register = None
88+
self.current_recording = ''

0 commit comments

Comments
 (0)