From 78fcf82238fb1ca7f84ed25fde0034610e673e91 2023-05-04 08:46:54 From: Matthias Bussonnier Date: 2023-05-04 08:46:54 Subject: [PATCH] Only enable "resume hinting" with right arrow if at the EOL (#14052) Fixes #14051 --- diff --git a/IPython/terminal/shortcuts/__init__.py b/IPython/terminal/shortcuts/__init__.py index f8241e0..2f7effb 100644 --- a/IPython/terminal/shortcuts/__init__.py +++ b/IPython/terminal/shortcuts/__init__.py @@ -277,7 +277,9 @@ AUTO_SUGGEST_BINDINGS = [ Binding( auto_suggest.resume_hinting, ["right"], - "default_buffer_focused & emacs_like_insert_mode", + "is_cursor_at_the_end_of_line" + " & default_buffer_focused" + " & emacs_like_insert_mode", ), ] diff --git a/IPython/terminal/shortcuts/filters.py b/IPython/terminal/shortcuts/filters.py index 5a28069..5a582af 100644 --- a/IPython/terminal/shortcuts/filters.py +++ b/IPython/terminal/shortcuts/filters.py @@ -54,6 +54,13 @@ def has_line_below() -> bool: @undoc @Condition +def is_cursor_at_the_end_of_line() -> bool: + document = get_app().current_buffer.document + return document.is_cursor_at_the_end_of_line + + +@undoc +@Condition def has_line_above() -> bool: document = get_app().current_buffer.document return document.cursor_position_row != 0 @@ -179,6 +186,7 @@ KEYBINDING_FILTERS = { "never": Never(), "has_line_below": has_line_below, "has_line_above": has_line_above, + "is_cursor_at_the_end_of_line": is_cursor_at_the_end_of_line, "has_selection": has_selection, "has_suggestion": has_suggestion, "vi_mode": vi_mode,