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.33k stars 714 forks source link

prompt, with completer, causes line state Wonkiness on Windows 10 when scroll buffer isn't empty #235

Open riverar opened 8 years ago

riverar commented 8 years ago

Isn't completely clear if this is a prompt issue or not, but here's the repro:

  1. Fire up command prompt, ensure it's using the new conhost (Use legacy console not selected).
  2. Insert a bunch of stuff into the scroll buffer and ensure window scrolls a bit down before continuing
  3. Using the toolkit API, prompt for input with a completer attached
  4. Specify input
  5. Note line state starts to get Wonky(tm) after a few inputs (1 or more). May need to repeat steps 2-4 a few more times.

Animated gif showing me simplying typing A-E, hitting enter between each letter. prompt

And the sample code

from prompt_toolkit import prompt
from prompt_toolkit.contrib.completers import WordCompleter
import sys

for i in range(50):
  print('--Scroll buffer filler--');
print('--End of scroll buffer filler--');

for i in range(5):
  html_completer = WordCompleter(['<html>', '<body>', '<head>', '<title>'])
  text = prompt('Prompt #%i: ' % i, completer = html_completer)
  print('Answer #%i: %s' % (i, text))
jonathanslenders commented 8 years ago

Thank you @riverar. The sample code is very helpful! I'll try to reproduce/debug/fix asap. (Sometimes, the windows console is tricky to get right, but we'll manage it.)