Skip to content

Commit b4c7ca0

Browse files
Merge pull request #4 from amjith/master
Fix C-w and C-u in the insert mode.
2 parents fd9cc0c + 11e8fc4 commit b4c7ca0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

prompt_toolkit/key_bindings/basic.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ def _(event):
140140
line.swap_characters_before_cursor()
141141

142142
@handle(Keys.ControlU, in_mode=InputMode.INSERT)
143+
@handle(Keys.ControlU, in_mode=InputMode.COMPLETE)
143144
def _(event):
144145
"""
145146
Clears the line before the cursor position. If you are at the end of
@@ -148,7 +149,12 @@ def _(event):
148149
deleted = line.delete_before_cursor(count=-line.document.get_start_of_line_position())
149150
line.set_clipboard(ClipboardData(deleted))
150151

152+
# Quit autocomplete mode.
153+
if event.input_processor.input_mode == InputMode.COMPLETE:
154+
event.input_processor.pop_input_mode()
155+
151156
@handle(Keys.ControlW, in_mode=InputMode.INSERT)
157+
@handle(Keys.ControlW, in_mode=InputMode.COMPLETE)
152158
def _(event):
153159
"""
154160
Delete the word before the cursor.
@@ -158,6 +164,10 @@ def _(event):
158164
deleted = line.delete_before_cursor(count=-pos)
159165
line.set_clipboard(ClipboardData(deleted))
160166

167+
# Quit autocomplete mode.
168+
if event.input_processor.input_mode == InputMode.COMPLETE:
169+
event.input_processor.pop_input_mode()
170+
161171
@handle(Keys.PageUp, in_mode=InputMode.COMPLETE)
162172
def _(event):
163173
line.complete_previous(5)

0 commit comments

Comments
 (0)