* perf(app): bound large diff row mounting Keep the existing vertical and horizontal scroll owners so virtualization does not change gesture or scrolling behavior. Reserve exact offscreen row heights while mounting only the visible window, and retain the full renderer when wrapping or editing reviews requires dynamic geometry. * perf(app): keep large diff reviews responsive Opening an inline editor changed the whole review action object, reconciled large syntax-token trees, and disabled row virtualization. Keep the expensive token subtree stable and preserve deterministic row geometry while the editor is open.\n\nBound server-side highlighting for pathological single lines and remove the unused client highlighter so the actual diff pipeline owns the limit. * test(app): check mounted diff typography Row virtualization can unmount a fixed diff row after scrolling. Assert the configured font size against a currently mounted row so the test continues to verify rendered typography without depending on window position. * test(app): stabilize Mermaid streaming coverage
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
interface HighlightLikeToken {
|
|
text: string;
|
|
}
|
|
|
|
interface StyledHighlightToken extends HighlightLikeToken {
|
|
style: string | null;
|
|
}
|
|
|
|
export function compactHighlightTokens(
|
|
tokens: readonly StyledHighlightToken[],
|
|
): StyledHighlightToken[] {
|
|
const compacted: StyledHighlightToken[] = [];
|
|
for (const token of tokens) {
|
|
if (token.text.length === 0) {
|
|
continue;
|
|
}
|
|
const previous = compacted.at(-1);
|
|
if (previous?.style === token.style) {
|
|
previous.text += token.text;
|
|
continue;
|
|
}
|
|
compacted.push({ text: token.text, style: token.style });
|
|
}
|
|
return compacted;
|
|
}
|
|
|
|
// Preserve row height when a gutter or diff cell is intentionally blank.
|
|
// Non-breaking space because the gutter <Text> uses numberOfLines={1}, which
|
|
// collapses a plain ASCII space to zero height on web.
|
|
export function formatDiffGutterText(lineNumber: number | null): string {
|
|
return lineNumber == null ? "\u00A0" : String(lineNumber);
|
|
}
|
|
|
|
export function formatDiffContentText(content: string | null | undefined): string {
|
|
return content && content.length > 0 ? content : " ";
|
|
}
|
|
|
|
export function hasVisibleDiffTokens(tokens: HighlightLikeToken[] | null | undefined): boolean {
|
|
return Boolean(tokens?.some((token) => token.text.length > 0));
|
|
}
|