Skip to content

[BUG] Trailing background color is trimmed when soft wrapping is enabled #3841

@KiGamji

Description

@KiGamji

Describe the bug
I was using the Windows Terminal initially. There is another bug with background leaking in our software with soft wrapping enabled, reproducible on both stable v1.23 and canary v1.25, with the code example below on Rich v14.1.0. But that is specific to Windows Terminal and is not related to the main issue, and I have confirmed, that unlike the background leak, the trailing background trimming is a Rich-specific issue, as it is present in various Terminal applications from Debian 13.

Code Example

from rich.console import Console
from rich.text import Text

# Force soft_wrap by narrow width
console = Console(soft_wrap=True, width=80)

text = Text()
text.append("x" * 60, style="white")
text.append(" | ", style="white")
text.append(" test str ", style="green on black")
text.append(" | ", style="white")  
text.append(" another str ", style="yellow on black")

console.print(text)
Image If you look closely, you can see that there is no trailing black space after the "another str" text.

Offtopic (Windows terminal leaking black background)

Click to expand Image

In most cases you can make it leak by resizing the window when it alters the text and it's background, and then resize it back again afterwards. Sometimes though, it gets leaked by itself when you align the terminal width in a specific size, probably related to #3838:

Image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions