From a803c4884f8320f3fcbc178181d22987302b35e2 Mon Sep 17 00:00:00 2001 From: Hajime Nakagami Date: Mon, 7 Oct 2024 15:25:14 +0900 Subject: [PATCH] CtrlE cancel completion. fix #55 --- pyvim/help.py | 3 ++- pyvim/key_bindings.py | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pyvim/help.py b/pyvim/help.py index 8ea2259..156d374 100644 --- a/pyvim/help.py +++ b/pyvim/help.py @@ -18,7 +18,8 @@ - Ctrl+n: select next candidate - Ctrl+p: select previsous candidate -- Ctrl+g: close autocompletion window +- Ctrl+g,Ctrl+y: accept and close autocompletion window +- Ctrl+e: cancen completion and close autocompletion window This key binding may change in the future. diff --git a/pyvim/key_bindings.py b/pyvim/key_bindings.py index 819f1e5..d81b3bc 100644 --- a/pyvim/key_bindings.py +++ b/pyvim/key_bindings.py @@ -461,6 +461,13 @@ def _unindent(event): buffer.cursor_position = cursor_position - 1 break + @kb.add("c-e", filter=vi_insert_mode) + def _cancel_completion(event: E) -> None: + """ + Cancel completion. Go back to originally typed text. + """ + event.current_buffer.cancel_completion() + @kb.add("enter", filter=in_insert_mode & is_multiline) def _newline(event: E) -> None: """