rich icon indicating copy to clipboard operation
rich copied to clipboard

[BUG] Live rendering issue with a specific Unicode character

Open frostbyte-ninja opened this issue 1 year ago • 1 comments

  • [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 encountered an issue with the Live module when using a specific Unicode character in the text. When this character is present, the Live rendering does not work as expected, and the first line of the text shows up multiple times.

Here's a sample code snippet that demonstrates the issue:

from rich.live import Live
from rich.markdown import Markdown
import time

def text_generator():
    text = """
    this line gets repeated

    1. text
       - line 🫧
       - line
       - line
       - line
    """
    for line in text.splitlines():
        words = line.split()
        for word in words:
            time.sleep(0.3)
            yield f"{word} "
        yield "\n"

with Live() as live:
    full_text = ""
    for word in text_generator():
        full_text += word
        live.update(Markdown(full_text))

Expected output:

this line gets repeated

 1 text

 • line 🫧
 • line
 • line
 • line

Actual output:

this line gets repeated
this line gets repeated
this line gets repeated
this line gets repeated
this line gets repeated
this line gets repeated
this line gets repeated
this line gets repeated

 1 text

 • line 🫧
 • line
 • line
 • line

I am not sure if this issue is somehow related to the one described in the FAQ under "Why does emoji break alignment in a Table or Panel?". If it turns out that this issue is indeed related to the FAQ entry, please feel free to close this ticket. Thank you!

Platform

Click to expand

Happens at least on Windows and Linux.

╭───────────────────────── <class 'rich.console.Console'> ─────────────────────────╮
│ A high level console interface.                                                  │
│                                                                                  │
│ ╭──────────────────────────────────────────────────────────────────────────────╮ │
│ │ <console width=160 ColorSystem.TRUECOLOR>                                    │ │
│ ╰──────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                  │
│     color_system = 'truecolor'                                                   │
│         encoding = 'utf-8'                                                       │
│             file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> │
│           height = 40                                                            │
│    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=160, height=40),             │
│                        legacy_windows=False,                                     │
│                        min_width=1,                                              │
│                        max_width=160,                                            │
│                        is_terminal=True,                                         │
│                        encoding='utf-8',                                         │
│                        max_height=40,                                            │
│                        justify=None,                                             │
│                        overflow=None,                                            │
│                        no_wrap=False,                                            │
│                        highlight=None,                                           │
│                        markup=None,                                              │
│                        height=None                                               │
│                    )                                                             │
│            quiet = False                                                         │
│           record = False                                                         │
│         safe_box = True                                                          │
│             size = ConsoleDimensions(width=160, height=40)                       │
│        soft_wrap = False                                                         │
│           stderr = False                                                         │
│            style = None                                                          │
│         tab_size = 8                                                             │
│            width = 160                                                           │
╰──────────────────────────────────────────────────────────────────────────────────╯
╭─── <class 'rich._windows.WindowsConsoleFeatures'> ────╮
│ Windows features available.                           │
│                                                       │
│ ╭───────────────────────────────────────────────────╮ │
│ │ WindowsConsoleFeatures(vt=False, truecolor=False) │ │
│ ╰───────────────────────────────────────────────────╯ │
│                                                       │
│ truecolor = False                                     │
│        vt = False                                     │
╰───────────────────────────────────────────────────────╯
╭────── Environment Variables ───────╮
│ {                                  │
│     'TERM': 'xterm-256color',      │
│     'COLORTERM': 'truecolor',      │
│     '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 │
│ }                                  │
╰────────────────────────────────────╯

markdown-it-py==3.0.0
mdurl==0.1.2
Pygments==2.17.2
rich==13.7.0

frostbyte-ninja avatar Jan 07 '24 10:01 frostbyte-ninja

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

github-actions[bot] avatar Jan 07 '24 10:01 github-actions[bot]