Skip to content

Fix empty-file placeholder clipping to one line after view rebuild#69

Merged
luca-chen198 merged 1 commit into
mainfrom
fix/empty-file-placeholder-clip
Jun 14, 2026
Merged

Fix empty-file placeholder clipping to one line after view rebuild#69
luca-chen198 merged 1 commit into
mainfrom
fix/empty-file-placeholder-clip

Conversation

@luca-chen198

Copy link
Copy Markdown
Member

Problem

With an empty document, the ghost-quote placeholder (PlaceholderLabelView) clipped to one line after the editor was rebuilt — e.g. switching to a graph/timeline view and back.

Cause

The placeholder draws with attributedText.draw(with: bounds, …), so its drawable height is the view's frame height, and placeholderFrame() derives that from the text view's frame height. For an empty document the text view sits at the one-line content height until the viewport-fill pass (applyManagedFrameSize) stretches it — and the container's restack deliberately never re-measures it. There is no layout() hook re-applying placeholderFrame(), so after a rebuild the placeholder gets stuck at one line and clips the multi-line quote.

Fix

Size the placeholder to the quote's own wrapped height, measured at the column width, instead of borrowing the text view's frame height:

height = max(bounds.height - inset.height, ceil(measuredTextHeight))

The normal (viewport-tall) case is unchanged because the frame height still wins the max; only the collapsed empty-doc case is corrected.

Test

swift build + swift test green (90 tests). Verified in the embedder (Nodes): empty file → graph view → back now shows the full quote.

🤖 Generated with Claude Code

With an empty document the ghost-quote placeholder clipped to one or two
lines after the editor was rebuilt — e.g. switching to a graph/timeline
view and back.

Root cause: the placeholder is a subview of the text view, so it's clipped
to the text view's frame height. An empty doc's text view should fill the
viewport (max(content, viewport)), but the viewport-fill pass can run while
the scroll view still has height 0 (pre-window layout on rebuild), leaving
the text view at its one-line content height — and the container's restack
never re-measures it. So the text view stayed ~one line tall and clipped
the multi-line quote.

Fix: when the placeholder is visible, re-run applyManagedFrameSize from
setPlaceholder (called every updateNSView) so the text view picks up the
now-valid viewport height and stops clipping. No-op once already sized;
only runs while the placeholder is shown, so non-empty docs are untouched.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@luca-chen198 luca-chen198 force-pushed the fix/empty-file-placeholder-clip branch from a1a1277 to 597678d Compare June 14, 2026 15:41
@luca-chen198 luca-chen198 merged commit b73670c into main Jun 14, 2026
1 check passed
@luca-chen198 luca-chen198 deleted the fix/empty-file-placeholder-clip branch June 14, 2026 15:44
luca-chen198 added a commit that referenced this pull request Jun 20, 2026
fitsContent height behavior (#75), BlockquoteStyle.extraLineHeight (#76), and fixes (#69/#70/#71/#73).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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