rich
rich copied to clipboard
[BUG] Text inside Live with vertical_overflow="visible" duplicating when above console.height instead of scrolling
- [x] I've checked docs and closed issues for possible solutions.
- [x] I can't find my issue in the FAQ.
Describe the bug
I try to create function to streaming from incoming text using both rich.markdown and rich.live. In this example, I use simple number loop with the delay to simulate the streaming. Here's the simple example:
import time
from rich.markdown import Markdown
from rich.live import Live
def stream_numbers(chunk_size=1):
for i in range(1, 11, chunk_size):
yield f"\n\n{i}"
time.sleep(0.01)
render_this = ""
with Live(render_this, auto_refresh=False, vertical_overflow="visible") as live:
print(f"Console height: {live.console.height}")
for entry in stream_numbers():
render_this += entry
live.update(Markdown(render_this), refresh=True)
Result:
1
1
(newline)
[...]
(newline)
10
Expected result: Output scrolling after excess console.height,
1
(newline)
[...]
(newline)
10
Result only breaking (duplicating) only when loop are above console.height. In this example, my console height are 18, and I try to print above it (19 newline).
Platform
Click to expand
Windows 11 with Python 3.10, Trying in: VSCode Terminal, Windows Terminal, and Cmder
╭───────────────────────── <class 'rich.console.Console'> ─────────────────────────╮
│ A high level console interface. │
│ │
│ ╭──────────────────────────────────────────────────────────────────────────────╮ │
│ │ <console width=100 ColorSystem.TRUECOLOR> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ color_system = 'truecolor' │
│ encoding = 'utf-8' │
│ file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> │
│ height = 24 │
│ is_alt_screen = False │
│ is_dumb_terminal = False │
│ is_interactive = True │
│ is_jupyter = False │
│ is_terminal = True │
│ legacy_windows = False │
│ no_color = False │
│ options = ConsoleOptions( │
│ size=ConsoleDimensions(width=100, height=24), │
│ legacy_windows=False, │
│ min_width=1, │
│ max_width=100, │
│ is_terminal=True, │
│ encoding='utf-8', │
│ max_height=24, │
│ justify=None, │
│ overflow=None, │
│ no_wrap=False, │
│ highlight=None, │
│ markup=None, │
│ height=None │
│ ) │
│ quiet = False │
│ record = False │
│ safe_box = True │
│ size = ConsoleDimensions(width=100, height=24) │
│ soft_wrap = False │
│ stderr = False │
│ style = None │
│ tab_size = 8 │
│ width = 100 │
╰──────────────────────────────────────────────────────────────────────────────────╯
╭── <class 'rich._windows.WindowsConsoleFeatures'> ───╮
│ Windows features available. │
│ │
│ ╭─────────────────────────────────────────────────╮ │
│ │ WindowsConsoleFeatures(vt=True, truecolor=True) │ │
│ ╰─────────────────────────────────────────────────╯ │
│ │
│ truecolor = True │
│ vt = True │
╰─────────────────────────────────────────────────────╯
╭────── Environment Variables ───────╮
│ { │
│ 'TERM': None, │
│ 'COLORTERM': None, │
│ 'CLICOLOR': None, │
│ 'NO_COLOR': None, │
│ 'TERM_PROGRAM': None, │
│ 'COLUMNS': None, │
│ 'LINES': None, │
│ 'JUPYTER_COLUMNS': None, │
│ 'JUPYTER_LINES': None, │
│ 'JPY_PARENT_PID': None, │
│ 'VSCODE_VERBOSE_LOGGING': None │
│ } │
╰────────────────────────────────────╯
platform="Windows"
We found the following entry in the FAQ which you may find helpful:
Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.
This is an automated reply, generated by FAQtory
It isn't possible to update content that has been scrolled off screen using Live. If you want something more dynamic, see Textual.