Skip to content

really bad flickering when there's lots of output #680

Open
@vlovich

Description

@vlovich

The prompt, right prompt & status bar (i.e. completion) are really bad (unusable) if there's a lot of output. Attached a repro case. Flickering of the completion can be improved by replacing erase to bottom with erase to end. The prompt still flickers at all times even with this (just uncomment out Vt100_Output.erase_down = flicker_fix to test it out). The rendering probably needs to better understand where the prompt cursor is & erase the non-prompt parts.

from prompt_toolkit.completion import WordCompleter
from prompt_toolkit.eventloop.defaults import use_asyncio_event_loop
from prompt_toolkit.patch_stdout import patch_stdout
from prompt_toolkit.shortcuts import CompleteStyle
from prompt_toolkit.shortcuts.prompt import prompt
from threading import Thread
from prompt_toolkit.output.vt100 import Vt100_Output

import time

def flicker_fix(self):
  self.write_raw('\x1b[K')

# Vt100_Output.erase_down = flicker_fix

def spam_print():
  while True:
    print("This is spam")
    time.sleep(0.01)

Thread(target=spam_print, daemon=True).start()

while True:
  with patch_stdout():
    prompt("> ", rprompt="test", complete_style=CompleteStyle.MULTI_COLUMN,
           completer=WordCompleter(list(chr(c) * 20 for c in range(ord("a"), ord("z")))))

Tested with OSX Terminal app (10.13.5)

Somewhat related to #547 although a different manifestation & a more serious consequence (especially when combined with #681).

Metadata

Metadata

Assignees

No one assigned

    Labels

    patch-stdoutpatch_stdout related issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions