prompt-toolkit / python-prompt-toolkit

Library for building powerful interactive command line applications in Python
https://python-prompt-toolkit.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
9.11k stars 718 forks source link

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

Open scopatz opened 8 years ago

scopatz commented 8 years ago

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

scopatz commented 8 years ago

I believe that @adqm and @gforsyth first noticed this issue.