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

Prompt placeholder text should not remain in the terminal when we have entered no text.

Open
#1,997 0 comments 0 reactions 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

Currently, when you use prompt like this:

def prompt(self, prompt_text: str) -> str:
    """Prompt user with prompt text."""
    return str(
        prompt(
            message=ANSI(f'{ChatColours.GRN.value}{prompt_text}{ChatColours.RST.value}'),
            placeholder=ANSI(f'{ChatColours.GRY.value}Some prompt text...{ChatColours.RST.value}'),
        )
    )

It will give you output similar to this when holding the enter key:
Image

This is misleading as it gives the impression that all lines are active and accepting input.

I recommend a change to make it so that only the last line (ie the only line accepting input) shows the placeholder text.
For example, it should be similar to this:
Image

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 with the prompt method and the placeholder argument shown in the issue, then trace how repeated prompts are rendered in the terminal. Done means that when multiple lines are present, placeholder text appears only on the last line that still accepts input; verify the behavior interactively by holding Enter.

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
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.