Skip to content

Draw only the visible lines of a log pane - #56

Merged
fedonman merged 1 commit into
mainfrom
fixed/draw-visible-log-lines
Sep 29, 2026
Merged

fedonman merged 1 commit into
mainfrom
fixed/draw-visible-log-lines

Conversation

@fedonman

@fedonman fedonman commented Sep 28, 2026 •

Copy link
Copy Markdown
Owner

A wrapped Paragraph also wraps every line above its scroll offset when it renders, and follow mode sits at the tail, so caching line_count would still leave one full wrap per frame. A new WrapIndex records where each line starts and which wrapped row it lands on. It is built once per log and pane width and extended with only the new lines as the log grows, and the stdout, stderr and custom panes now hand ratatui just the lines on screen. A frame takes about 0.16 ms at both 1 MB and 20 MB. Follow mode also stops leaving two blank rows under the last line, and these panes keep following past 65,535 rows.

Closes #20

The stdout, stderr and custom panes measured their content with
Paragraph::line_count and then rendered it scrolled to the tail, and
both wrap every line of the log, so each frame cost time in proportion
to the log's size: about 65 ms per MB. A WrapIndex now records where
each line starts and which wrapped row it lands on. It is built once
per log and width and extended with just the new lines as a log grows,
and each frame hands ratatui only the lines on screen, so a frame takes
the same fraction of a millisecond at 1 MB and 20 MB.

The row count no longer includes the border, which line_count added,
so follow mode stops leaving two blank rows under the last line, and
the scroll offset given to ratatui is now within one line, so these
panes keep following past 65,535 rows.
@fedonman
fedonman force-pushed the fixed/draw-visible-log-lines branch from d103855 to 0205584 Compare September 29, 2026 09:17
@fedonman
fedonman merged commit d6c341b into main Sep 29, 2026
6 checks passed
@fedonman
fedonman deleted the fixed/draw-visible-log-lines branch September 29, 2026 09:18
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.

[Bug]: Every redraw re-wraps the entire log buffer

1 participant