Does not respond after pressing ^@
Closed this issue · 3 comments
Atry commented
In ipython, which uses prompt-toolkit, when I press ^@(Ctrl+Shift+2), the terminal becomes frozen, does not respond to any key input any more. The behavior is different from GNU Readline, where ^@ is set-mark, to start selecting a region.
prompt-toolkit version: 3.0.50
OS: Linux (Ubuntu 22.04)
Atry commented
I think the problem is that ^@ is \x00, which results in bugs in prompt-toolkit.
Atry commented
Here is a test to demonstrate that \x00 is not handled properly.
Python 3.12.8 (main, Dec 3 2024, 18:42:41) [GCC 13.3.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.32.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from prompt_toolkit.input import create_pipe_input
...: from prompt_toolkit.output import DummyOutput
...: from prompt_toolkit import PromptSession
...:
...:
...: with create_pipe_input() as pipe_input:
...: session = PromptSession(input=pipe_input, output=DummyOutput())
...: pipe_input.send_bytes(b"a quick \x00red\x18\x18\x0Bbrown fox\n")
...:
...: line = await session.prompt_async()
...: line
Out[1]: 'a quick '
Atry commented
OK. It's not frozen. It's the selection mode.
But the selection mode in prmpt-toolkit behaves very differently from GNU Readline.