fix: enable word wrapping for syntax-highlighted code output

Long code lines were clipped at the terminal width, making them
unreadable. Pass word_wrap=True to all Syntax() calls so lines wrap
instead of being cut off.
This commit is contained in:
2026-04-04 14:47:21 -07:00
parent 579df72869
commit 7df3acde9b
2 changed files with 69 additions and 3 deletions

View File

@@ -83,12 +83,20 @@ def render(
except (SyntaxError, ValueError):
log_debug(options.debug, "render: invalid JSON, falling back to syntax")
renderable = Syntax(
content, "json", theme=options.theme, line_numbers=line_numbers
content,
"json",
theme=options.theme,
line_numbers=line_numbers,
word_wrap=True,
)
else:
try:
renderable = Syntax(
content, file_type, theme=options.theme, line_numbers=line_numbers
content,
file_type,
theme=options.theme,
line_numbers=line_numbers,
word_wrap=True,
)
except Exception:
log_debug(
@@ -96,7 +104,11 @@ def render(
f"render: unknown lexer {file_type!r}, falling back to plain text",
)
renderable = Syntax(
content, "text", theme=options.theme, line_numbers=line_numbers
content,
"text",
theme=options.theme,
line_numbers=line_numbers,
word_wrap=True,
)
padded = Padding(renderable, (1, 2))