Skip to content

[BUG] Tree is always cropped with soft_wrap=True #3785

Open
@nfergu

Description

@nfergu

Describe the bug

When I print a Tree to the console it is always cropped when soft_wrap=True is set, even if I also specify the crop=False and overflow="ignore" arguments.

Here is a minimal example:

from rich.console import Console
from rich.tree import Tree

tree = Tree("Monkey Puzzle")
node = tree.add("root")
for i in range (20):
    node = node.add(f"branch with longish name ({i})")

console = Console()
console.print(tree, soft_wrap=True, crop=False, overflow="ignore")

This produces the following output, where the text is truncated. But I would expect the text not to be truncated.

Image

Platform

Click to expand

What platform (Win/Linux/Mac) are you running on? What terminal software are you using?

Mac (OS version 15.5). Standard Apple terminal.

I may ask you to copy and paste the output of the following commands. It may save some time if you do it now.

If you're using Rich in a terminal:

python -m rich.diagnose
pip freeze | grep rich

If you're using Rich in a Jupyter Notebook, run the following snippet in a cell
and paste the output in your bug report.

from rich.diagnose import report
report()

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