Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dfb5353

Browse files
committed
Accept with cursor in place with ctrl + down, move left after accepting
1 parent 43d6a9b commit dfb5353

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

IPython/terminal/shortcuts/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,9 @@ def not_inside_unclosed_string():
358358
auto_suggest.accept_character
359359
)
360360
kb.add("left", filter=has_suggestion & has_focus(DEFAULT_BUFFER))(
361+
auto_suggest.accept_and_move_cursor_left
362+
)
363+
kb.add("c-down", filter=has_suggestion & has_focus(DEFAULT_BUFFER))(
361364
auto_suggest.accept_and_keep_cursor
362365
)
363366
kb.add("backspace", filter=has_suggestion & has_focus(DEFAULT_BUFFER))(

IPython/terminal/shortcuts/auto_suggest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,12 @@ def accept_and_keep_cursor(event: KeyPressEvent):
164164
if suggestion:
165165
buffer.insert_text(suggestion.text)
166166
buffer.cursor_position = old_position
167-
else:
168-
nc.backward_char(event)
167+
168+
169+
def accept_and_move_cursor_left(event: KeyPressEvent):
170+
"""Accept autosuggestion and move cursor left"""
171+
accept_and_keep_cursor(event)
172+
nc.backward_char(event)
169173

170174

171175
def backspace_and_resume_hint(event: KeyPressEvent):

0 commit comments

Comments
 (0)