From 8af5442ee0d7c34d0066c6651ac2d364790c6d6c Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Thu, 8 Dec 2022 17:12:57 -0900 Subject: [PATCH 1/2] Fix vi mode escape delay --- IPython/terminal/shortcuts.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/IPython/terminal/shortcuts.py b/IPython/terminal/shortcuts.py index 7d6de8b3b04..01072cd99a1 100644 --- a/IPython/terminal/shortcuts.py +++ b/IPython/terminal/shortcuts.py @@ -68,9 +68,14 @@ def reformat_and_execute(event): reformat_text_before_cursor(event.current_buffer, event.current_buffer.document, shell) event.current_buffer.validate_and_handle() + @Condition + def ebivim(): + return shell.emacs_bindings_in_vi_insert_mode + kb.add('escape', 'enter', filter=(has_focus(DEFAULT_BUFFER) & ~has_selection & insert_mode + & ebivim ))(reformat_and_execute) kb.add("c-\\")(quit) @@ -333,10 +338,6 @@ def _(event): if sys.platform == "win32": kb.add("c-v", filter=(has_focus(DEFAULT_BUFFER) & ~vi_mode))(win_paste) - @Condition - def ebivim(): - return shell.emacs_bindings_in_vi_insert_mode - focused_insert_vi = has_focus(DEFAULT_BUFFER) & vi_insert_mode @kb.add("end", filter=has_focus(DEFAULT_BUFFER) & (ebivim | ~vi_insert_mode)) From 11dd2521aee4a87d68f2244d6fee86c6e1873fcd Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Tue, 3 Jan 2023 12:00:52 +0100 Subject: [PATCH 2/2] please formatter --- IPython/terminal/shortcuts.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/IPython/terminal/shortcuts.py b/IPython/terminal/shortcuts.py index 01072cd99a1..6ca91ec31ba 100644 --- a/IPython/terminal/shortcuts.py +++ b/IPython/terminal/shortcuts.py @@ -72,11 +72,11 @@ def reformat_and_execute(event): def ebivim(): return shell.emacs_bindings_in_vi_insert_mode - kb.add('escape', 'enter', filter=(has_focus(DEFAULT_BUFFER) - & ~has_selection - & insert_mode - & ebivim - ))(reformat_and_execute) + kb.add( + "escape", + "enter", + filter=(has_focus(DEFAULT_BUFFER) & ~has_selection & insert_mode & ebivim), + )(reformat_and_execute) kb.add("c-\\")(quit)