I believe click_repl is missing a loop over split_lines() or similar here.
(This may be more difficult when lines contain a " " string continued over multiple lines - I didn't check that).
As a workaround, I vendored click_repl, and modified def _get_command():
def get_command():
# 2024-01-24, tk: HACK
#
# Workaround for multi-line paste by overriding a function in prompt-toolkit.
#
# I didn't find an official way to disable the bracketed_paste feature,
# because it's always enabled by renderer.py, and handled at a low level
# in input/vt100_parser.py . Overriding the key binding, etc. didn't help.
#
# Please improve if you know a better method!
#
# See https://github.com/click-contrib/click-repl/issues/111
#
session.output.enable_bracketed_paste = session.output.disable_bracketed_paste
return session.prompt()
Pasting multiple lines does not execute the commands line-by-line as expected.
prompt-toolkit unconditionally activates the "bracketed paste" feature of the terminal emulator:
So when I paste multiple lines, get_command() returns a string containing multiple lines:
I believe click_repl is missing a loop over split_lines() or similar here. (This may be more difficult when lines contain a " " string continued over multiple lines - I didn't check that).
As a workaround, I vendored click_repl, and modified
def _get_command():