fix: seed code-block cache on programmatic document load

updateCodeBlockSelection was only ever called from the two AppKit
text-delegate callbacks (textDidChange / selection-changed), never
from the programmatic rebuildTextStorageAndStyle load path. Line
number gutters (and the built-in copy-code button) stayed empty on a
cold document open until the user's first click or keystroke.
Threads the rebuild's own parsed document into the same call instead
of leaving cachedCodeBlockTokens empty until the next real edit.
This commit is contained in:
2026-08-20 13:49:43 +01:00
parent 707dde14a9
commit 3c3a5865bd
@@ -185,6 +185,13 @@ extension NativeTextViewCoordinator {
previousActiveTokenIndices = activeTokenIndices
previousCaretLocation = finalSelection.location
previousSelectedRange = finalSelection
// FIX: seed cachedCodeBlockTokens on the programmatic load path too
// it was previously only populated by the AppKit text-delegate
// callbacks (textDidChange / selection-changed), so code-block
// overlays (line-number gutters, the built-in copy button) stayed
// empty on a cold document open until the user's first keystroke.
updateCodeBlockSelection(textView: textView, parsed: parsed)
}
// Reconcile wide-table overlays after layout settles.