prompt-toolkit / prompt-toolkit/python-prompt-toolkit

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

Open
#1,933 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
10.6k
Forks
815
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided demo.py with prompt_toolkit 3.0.47 and resizing the terminal while input is active. Trace prompt_toolkit's terminal-resize and redraw handling to identify why the prompt and current input are emitted repeatedly. Done means resizing no longer duplicates the visible prompt or input, while normal multiline input remains functional.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.