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

Cursor misaligned in multiline mode when terminal width less than prompt len

Open
#213 1 comment 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

The cursor in multiline mode starts doing weird things if the prompt text is too large for the terminal size. For example, for a small terminal, just cd'ing into a directory will place the cursor at the end of the second line as seen by <C> below.

scopatz@localhost ~ $ xonsh --shell-type=prompt_toolkit
scopatz@localhost ~ $ cd xonsh/xonsh/ptk/__pycache__
                      /
scopatz@localhost ~/xonsh/xonsh/ptk/__pycache__ xonf
ig $                                               <C>          

Then if you start typing, it will overwrite the first line:

scopatz@localhost ~ $ xonsh --shell-type=prompt_toolkit
scopatz@localhost ~ $ cd xonsh/xonsh/ptk/__pycache__
                      /
scopatz@localhost ~/xonsh/xonsh/ptk/__pycache__ echo
xonfig $                                      <C>

Resizing the terminal so that the prompt fits on one line, fixes the prompt dynamically:

scopatz@localhost ~/xonsh/xonsh/ptk/__pycache__ xonfig $ echo

This is on prompt-toolkit v0.57

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

Reproduce the issue with prompt-toolkit v0.57 using a terminal narrower than the prompt and multiline mode. Trace the prompt rendering and cursor placement behavior; done means typing after a wrapped prompt no longer overwrites the first line and resizing still corrects the display.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.