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

Terminal resize causes prompt_toolkit to print the prompt and the current input again and again #1933

Open
KoStard opened this issue Oct 24, 2024 · 1 comment

Comments

@KoStard
Copy link

KoStard commented Oct 24, 2024

I encountered this issue both on MacOS and Ubuntu. I used different terminals, verified with Kitty and Alacritty.

Minimal Reproducible Example

import prompt_toolkit

def demo():
    session = prompt_toolkit.PromptSession(multiline=True)
    print("Enter your text (type 'exit' to quit):")
    
    while True:
        try:
            user_input = session.prompt('> ')
            if user_input.strip().lower() == 'exit':
                print("Exiting...")
                break
            print(f"You entered:\n{user_input}")
        except (EOFError, KeyboardInterrupt):
            print("Exiting...")
            break

if __name__ == "__main__":
    demo()

Description

I am developing HermesCLI, which is a chat app, and I use prompt_toolkit to handle multiline input. This issue frustrates the users as their history now gets lots of noise. When the terminal is resized, the prompt and the current input are printed repeatedly, cluttering the interface.

Steps to Reproduce

  1. Run the provided minimal example.
  2. Resize the terminal window.
  3. Observe the repeated printing of the prompt and current input.

Expected Behavior

The prompt and current input should not be printed again when the terminal is resized.

Environment

  • Operating System: MacOS and Ubuntu
  • Terminals: Kitty and Alacritty
  • prompt_toolkit version: prompt_toolkit==3.0.47

Additional Information

❯ python demo.py 
Enter your text (type 'exit' to quit):
> hello



> hello


> hello

> hello

@KoStard
Copy link
Author

KoStard commented Oct 24, 2024

Related: #1675
Possibly related: #29

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