Skip to content

[BUG] Error in measuring width of multiline text of only whitespace #1133

@castor-v-pollux

Description

@castor-v-pollux

Describe the bug
When rendering a multiline Text made up of only spaces, Rich fails to measure its width. It seems that Rich will use the sum of each line's width rather than the maximum of them.

To Reproduce

from rich import print
from rich.panel import Panel
from rich.text import Text
print(Panel.fit(Text(' \n  \n   ', style = 'on green'), padding = 0))

Instead of rendering a panel of width 3, it turns out 6. As long as the Text contains non-whitespace characters, this phenomenon disappears.

Platform
I tried it on both windows 7/10 cmd and default terminal in linux, and encountered the same problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedTask was acceptedbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions