Skip to content

fix(markdown_viewer): wrap long lines in table cells to fit terminal width#63

Open
sideshowbarker wants to merge 1 commit intoSkardyy:mainfrom
sideshowbarker:feat/table-cell-wrapping
Open

fix(markdown_viewer): wrap long lines in table cells to fit terminal width#63
sideshowbarker wants to merge 1 commit intoSkardyy:mainfrom
sideshowbarker:feat/table-cell-wrapping

Conversation

@sideshowbarker
Copy link
Contributor

Problem: When a table cell contains a line longer than the terminal width, the line unexpectedly doesn't get wrapped within the cell.

Cause: Column widths were just computed as the max content width of any cell in the column — with no regard for the terminal width.

Fix: After computing column widths, cap them to fit within the terminal using a "waterfall" algorithm that keeps narrow columns at their natural size and only shrinks wider columns. Lines that exceed the capped width are wrapped using a new ANSI-aware wrap_cell_text function that preserves formatting across wrapped lines.

…width

Problem: When a table cell contains a line longer than the terminal
width, the line unexpectedly doesn’t get wrapped within the cell.

Cause: Column widths were just computed as the max content width of any
cell in the column — with no regard for the terminal width.

Fix: After computing column widths, cap them to fit within the terminal
using a “waterfall” algorithm that keeps narrow columns at their natural
size and only shrinks wider columns. Lines that exceeds the capped width
are wrapped using a new ANSI-aware wrap_cell_text function that
preserves formatting across wrapped lines.
@sideshowbarker sideshowbarker force-pushed the feat/table-cell-wrapping branch from 5bdadc5 to 5c08de4 Compare March 15, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant