Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling multi-line bracketed paste #111

Open
thomask77 opened this issue Jan 26, 2024 · 0 comments
Open

Handling multi-line bracketed paste #111

thomask77 opened this issue Jan 26, 2024 · 0 comments

Comments

@thomask77
Copy link

thomask77 commented Jan 26, 2024

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():

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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant