From 11e8fc40edf34571d6ea5ce4d61f70127206c5bc Mon Sep 17 00:00:00 2001 From: Amjith Ramanujam Date: Sun, 21 Sep 2014 10:44:49 -0700 Subject: [PATCH] Fix C-w and C-u in the insert mode. --- prompt_toolkit/key_bindings/basic.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/prompt_toolkit/key_bindings/basic.py b/prompt_toolkit/key_bindings/basic.py index 66b65d53a..99d3e7325 100644 --- a/prompt_toolkit/key_bindings/basic.py +++ b/prompt_toolkit/key_bindings/basic.py @@ -140,6 +140,7 @@ def _(event): line.swap_characters_before_cursor() @handle(Keys.ControlU, in_mode=InputMode.INSERT) + @handle(Keys.ControlU, in_mode=InputMode.COMPLETE) def _(event): """ Clears the line before the cursor position. If you are at the end of @@ -148,7 +149,12 @@ def _(event): deleted = line.delete_before_cursor(count=-line.document.get_start_of_line_position()) line.set_clipboard(ClipboardData(deleted)) + # Quit autocomplete mode. + if event.input_processor.input_mode == InputMode.COMPLETE: + event.input_processor.pop_input_mode() + @handle(Keys.ControlW, in_mode=InputMode.INSERT) + @handle(Keys.ControlW, in_mode=InputMode.COMPLETE) def _(event): """ Delete the word before the cursor. @@ -158,6 +164,10 @@ def _(event): deleted = line.delete_before_cursor(count=-pos) line.set_clipboard(ClipboardData(deleted)) + # Quit autocomplete mode. + if event.input_processor.input_mode == InputMode.COMPLETE: + event.input_processor.pop_input_mode() + @handle(Keys.PageUp, in_mode=InputMode.COMPLETE) def _(event): line.complete_previous(5)