prompt-toolkit / python-prompt-toolkit

Library for building powerful interactive command line applications in Python
https://python-prompt-toolkit.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
9.1k stars 717 forks source link

Vim keybindings - first use of 'bb' goes into insert mode #1797

Open matthew-brett opened 8 months ago

matthew-brett commented 8 months ago

Please forgive me for the reproducer here, and the report - I am happy to be guided how to report better, but

I am using prompt_toolkit via IPython.

For a while now, I have noticed that, when pressing bb in normal mode, the line goes into insert mode for the second b, and indeed I get a literal b in the text. This is inconvenient, as bb is a very common movement sequence for me.

Is there any better information I can provide by way of a bug report?

matthew-brett commented 7 months ago

More observations on this rather disabling and elusive bug.

In IPython at least - I seem only get this effect in my first attempt at moving in the text (in command mode). After the first attempt at bb movement (to move back two words), it goes into insert mode and inserts 'b'. When I exit insert mode, bb functions normally while I continue to edit the line.

It appears I have to be quick to trigger the bug. If I paste some text and wait one second before editing, I do not get the bug. If I press b and then wait half a second or so, and press b again, I do not get the bug.

These effects are very reproducible in IPython at least.

jonathanslenders commented 5 months ago

This looks like an IPython specific bug. ptpython does behave correctly. Probably best is to open an IPython issue.

Most likely it's caused by this line: https://github.com/ipython/ipython/blob/4c49335ef3e8bff8bee006228a983762d5ce5e4e/IPython/terminal/shortcuts/__init__.py#L308C43-L308C43 From what I see, this was added to have "Emacs" bindings" in "Vi" mode.