Skip to content

Keep rendered tables in sync during live resize - #152

Open
YishenTu wants to merge 1 commit into
nodes-app:mainfrom
YishenTu:fix/live-table-resize
Open

Keep rendered tables in sync during live resize#152
YishenTu wants to merge 1 commit into
nodes-app:mainfrom
YishenTu:fix/live-table-resize

Conversation

@YishenTu

@YishenTu YishenTu commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • reraster and restyle rendered tables before each physical AppKit live-resize callback returns
  • preserve exact fractional geometry, symmetric insets, document height, and wide-table overlay sizing
  • coalesce ordinary width writes and limit resize work to indexed table paragraphs

Root cause

NativeTextView updated its frame and text-container width synchronously, but table restyling was scheduled asynchronously. A physical AppKit window resize can remain inside its nested event-tracking operation without servicing that work between resize callbacks. The window could therefore paint each frame with the previous table image, then execute multiple redundant restyles after mouse-up.

PR #117 made initially narrow tables eligible for width-change restyling, but did not change this scheduling contract or exercise a real NativeTextView live-resize path.

Implementation

  • track physical live-resize state at the scroll-view boundary and synchronously complete the table raster, attribute, height, and overlay transaction
  • retain per-run-loop coalescing for ordinary and programmatic width changes
  • keep post-resize synchronization armed only while clip, document, and text-view widths show an unconsumed hosted-layout mismatch
  • derive width from the live text-view geometry when the text container tracks it, while preserving fixed reading-column ownership
  • use lossless fractional-width cache keys and a floating-point epsilon for the scrollable-table transition
  • reconcile wide-table overlays immediately and keep fixed-column breakout overlays attached to their host width

Verification

  • arch -arm64 swift test — 363 tests passed across 59 suites
  • arch -arm64 swift build
  • git diff --check upstream/main
  • regression coverage uses a real NSWindow, ClampedScrollView, NativeTextViewContainer, NativeTextView, and TextKit 2 stack, including event-tracking, intermediate and final widths, delayed hosted layout, fractional widths, multi-table documents, height changes, and wide overlays

Trade-off

Physical live resize synchronously rasterizes all tables in the current document on the main thread so the frame being painted is geometrically correct. Width changes outside physical live resize remain coalesced to the latest value per run-loop turn.

Apply width-dependent table styling before each physical resize callback returns, while coalescing ordinary width writes. Track fractional geometry, trailing hosted layout propagation, document height, and wide-table overlays with real AppKit regression coverage.
@YishenTu
YishenTu force-pushed the fix/live-table-resize branch from c1982a9 to 9e05936 Compare August 13, 2026 05:04
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