From 11011b059a2bbd95006ce3a57e8d1cdc1e481eea 2023-01-22 20:29:33 From: krassowski <5832902+krassowski@users.noreply.github.com> Date: 2023-01-22 20:29:33 Subject: [PATCH] Add missing line_below/line_above conditions --- diff --git a/IPython/terminal/shortcuts/__init__.py b/IPython/terminal/shortcuts/__init__.py index fc870f0..6d68c17 100644 --- a/IPython/terminal/shortcuts/__init__.py +++ b/IPython/terminal/shortcuts/__init__.py @@ -52,12 +52,14 @@ def has_focus(value: FocusableElement): return Condition(tester) +@undoc @Condition def has_line_below() -> bool: document = get_app().current_buffer.document return document.cursor_position_row < len(document.lines) - 1 +@undoc @Condition def has_line_above() -> bool: document = get_app().current_buffer.document @@ -378,12 +380,13 @@ def create_ipython_shortcuts(shell, for_all_platforms: bool = False) -> KeyBindi & has_suggestion & has_focus(DEFAULT_BUFFER), )(auto_suggest.swap_autosuggestion_down(shell.auto_suggest)) - kb.add("up", filter=navigable_suggestions & has_focus(DEFAULT_BUFFER))( - auto_suggest.up_and_update_hint - ) - kb.add("down", filter=navigable_suggestions & has_focus(DEFAULT_BUFFER))( - auto_suggest.down_and_update_hint - ) + kb.add( + "up", filter=has_line_above & navigable_suggestions & has_focus(DEFAULT_BUFFER) + )(auto_suggest.up_and_update_hint) + kb.add( + "down", + filter=has_line_below & navigable_suggestions & has_focus(DEFAULT_BUFFER), + )(auto_suggest.down_and_update_hint) kb.add("right", filter=has_suggestion & has_focus(DEFAULT_BUFFER))( auto_suggest.accept_character )