Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/measurement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ export function getSegmentBreakableFitAdvances(
emojiCorrection: number,
mode: BreakableFitMode,
): number[] | null {
// The cached result is mode-agnostic: the current call sites guarantee that
// a given segment text always arrives with the same mode, because mode is
// determined by isNumericRunSegment(text) (text-deterministic) and the
// session-invariant engine profile. If a future caller breaks this
// invariant, the cache will silently return the wrong advances.
if (metrics.breakableFitAdvances !== undefined) return metrics.breakableFitAdvances

const graphemeSegmenter = getSharedGraphemeSegmenter()
Expand Down