Skip to content

refresh_lines repaints a widget's lines without rendering its content again - #246

Merged
trissim merged 1 commit into
mainfrom
refresh-lines
Nov 6, 2026
Merged

trissim merged 1 commit into
mainfrom
refresh-lines

Conversation

@trissim

@trissim trissim commented Nov 6, 2026

Copy link
Copy Markdown

1 commit, widget.py +26/-10. A full refresh() goes through _set_dirty(), which adds the whole widget to _dirty_regions (widget.py:2556), so render_line rebuilds the content. That's right when the content changed, and wrong for an animation frame that only tints the same lines. Toad's arrival fades rebuilt every Markdown block and row of a fading entry on every frame, and rich Style construction was 19% of the live main thread.

  • Widget.refresh_lines() invalidates and repaints every line from the content already rendered, so render_line runs again and _render_content doesn't.
  • _invalidate_lines() is the half _set_dirty() already did (clear the styles cache, mark the lines, add the repaint region). It's now one method both callers use, not a second copy.

Proof: a probe in Toad's real app, over one arrival fade, measured content rebuilds of the unchanged entry at 9 in 21 frames before and 1 in 27 frames after (the initial render). Screens, markdown (including fence cache and initial publication), refresh-callback, bindings, containers, data table, text area, option list, tree and animations tests: 639 passed. The 3 test_editor_state reds fail identically on clean main.

🤖 Generated with Claude Code

… again

A full refresh() reaches _set_dirty(), which adds the whole widget to _dirty_regions, so
render_line rebuilds the content: right for "the content changed", wrong for an animation
frame that only tints the same lines in render_line. Toad's arrival fades did exactly that,
rebuilding every Markdown block and row of a fading entry each frame (rich Style construction
was 19% of the live main thread). refresh_lines() invalidates and repaints every line from
the content already rendered; _invalidate_lines is the half _set_dirty already did, now
owned once and inherited by both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 6, 2026 06:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

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.

2 participants