From bc12e6dcb215cb6cea47f57f7a58ecf3a89e3b56 2022-04-04 19:40:37 From: Blazej Michalik Date: 2022-04-04 19:40:37 Subject: [PATCH] Fix empty autosuggestions bugging out the end key The `nc.end_of_line(event)` line was never triggered. During writing this, the `Suggestion` class from prompt-toolkit has no `__bool__` implemented, which meant its objects always evaluate to `True`, even if `b.suggestion.text == ''`. The above resulted in the end key being unusable after an autosuggestion has been accepted by the user. --- diff --git a/IPython/terminal/shortcuts.py b/IPython/terminal/shortcuts.py index 3a0017c..615397a 100644 --- a/IPython/terminal/shortcuts.py +++ b/IPython/terminal/shortcuts.py @@ -271,7 +271,7 @@ def create_ipython_shortcuts(shell): def _apply_autosuggest(event): b = event.current_buffer suggestion = b.suggestion - if suggestion: + if suggestion is not None and suggestion.text: b.insert_text(suggestion.text) else: nc.end_of_line(event)