Closed
Description
- I've checked docs and closed issues for possible solutions.
- I can't find my issue in the FAQ.
Describe the bug
I originally discovered this issue in Textual, but it looks like a possible bug in Syntax
.
Here's a MRE with a narrow console width to demonstrate. The first syntax with wrapping enabled works as expected, however notice that the syntax with padding is missing some code:
from rich.console import Console
from rich.syntax import Syntax
EXAMPLE_CODE = """\
class ListViewExample(App):
def compose(self) -> ComposeResult:
yield ListView(
ListItem(Label("One")),
ListItem(Label("Two")),
ListItem(Label("Three")),
)
yield Footer()\
"""
console = Console(width=32)
console.print("Syntax with wrapping enabled:", style="bold")
syntax = Syntax(EXAMPLE_CODE, lexer="python", word_wrap=True)
console.print(syntax)
console.print()
console.print("After adding padding:", style="bold")
syntax.padding = (1, 2)
console.print(syntax)
Tested with the latest version of rich (14.0.0) on Linux.