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

Indent behaviour on paste is different in terminal and AWS CloudShell #1908

Open
iakov-aws opened this issue Aug 17, 2024 · 1 comment
Open

Comments

@iakov-aws
Copy link

iakov-aws commented Aug 17, 2024

Hello,

I notice a difference in behavior of following code in terminal win/macos/linux vs AWS CloudShell.

from prompt_toolkit import prompt
answer = prompt( "Multiline input: >\", multiline=True)
print(answer)

In AWS CloudShell the text pasted is
image

In other terminals paste works as expected
image

As per doc multi-line activates indent mode and it works fine. But on AWS CloudShell paste works combined with indent but with other terminals it works some other way not indenting the pasted input.

Most likely prompt-toolkit detects paste action but in AWS CloudShell the paste mechanism is not detectable(?).

Is there a way to deactivate auto indent on multi-line mode any other way to make paste work on AWS CloudShell ?

@iakov-aws
Copy link
Author

Here is one possible option to do that. Wonder if there are better ways?

import os
from prompt_toolkit import PromptSession

def prompt(**kwargs):
    session = PromptSession(**kwargs)
    if os.environ.get('AWS_EXECUTION_ENV') == 'CloudShell':
       session.app.paste_mode = lambda: True # avoid auto-indent in CloudShell
    return session.prompt()

@iakov-aws iakov-aws changed the title Indent behaviour is different in terminal and AWS CloudShell Indent behaviour on paste is different in terminal and AWS CloudShell Aug 19, 2024
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