-
Notifications
You must be signed in to change notification settings - Fork 738
Open
Description
The app:
from prompt_toolkit import Application
from prompt_toolkit.buffer import Buffer
from prompt_toolkit.layout.containers import Window, HSplit
from prompt_toolkit.layout.controls import BufferControl
from prompt_toolkit.layout.layout import Layout
from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit.widgets import TextArea
kb = KeyBindings()
@kb.add('c-q')
def exit_(event):
event.app.exit()
buffer1 = Buffer() # Editable buffer.
root_container = HSplit([
TextArea(
prompt='Type something: ',
multiline=False,
wrap_lines=False,
accept_handler=lambda buff: buffer1.insert_text(f"accept_handler called: {buff.text}\n"),
),
Window(height=1, char='-'),
Window(content=BufferControl(buffer=buffer1)),
])
layout = Layout(root_container)
app = Application(key_bindings=kb, layout=layout, full_screen=True)
app.run()
When multiline=False
, pressing enter should trigger accept_handler
.
However, when pasting multi-line text to the console, TextArea
draws a new line then scroll down. In this case, accept_handler
won't be triggered.
Another way to trigger this bug is to type very fast when the computer is slow. I guess it works similarly as copy-pasting.
Windows 10
prompt_toolkit 3.0.47
cmd.exe + Windows Terminal
Splines
Metadata
Metadata
Assignees
Labels
No labels