perf(vcs): virtualize the all-in-one diff's file blocks (#5336)

The all-in-one diff mounted an editor pair for every file, so large changes created hundreds of editors and long frames. Only blocks near the viewport are mounted now (overscan 4; the focused block and, with autosave off, blocks with unsaved staged edits stay mounted), each block keeps its last height, and a remounted block gets back its selections and expanded unchanged lines. Most of a block's mount cost was three themes created per editor (seamlessSelection, movedCodeHighlights, fontExtension), each adding rules and restyling the page; they are now created once per value. Also fixes a stale-response race in gitDiffEntries.

Co-authored-by: audichuang <[email protected]>
Цей коміт міститься в:
audichuang authored and GitHub committed 2026-11-24 21:50:20 +08:00
1 джерело 644a2d5784
коміт ff1ef2b2f0
14 files changed
+986 -113

No files matched your search

+21 -18
Переглянути файл
@@ -94,24 +94,27 @@ function decorations(view: EditorView, words: boolean): DecorationSet {
return Decoration.set(ranges, true);
}
// One module for every diff: each new theme adds its rules to the page again, restyling it all.
const movedCodeTheme = EditorView.baseTheme({
".cm-diffMoved": { boxShadow: "inset 3px 0 0 color-mix(in srgb, var(--accent) 70%, transparent)" },
".cm-diffMoveEdit-deleted": { backgroundColor: "color-mix(in srgb, var(--diff-deleted) 85%, transparent)" },
".cm-diffMoveEdit-inserted": { backgroundColor: "color-mix(in srgb, var(--diff-inserted) 85%, transparent)" },
".cm-diffMoveLink": {
marginLeft: "12px",
padding: "0 4px",
fontFamily: "var(--font-ui)",
fontSize: "var(--fs-small)",
color: "var(--link)",
background: "var(--bg-app)",
border: "1px solid var(--border)",
borderRadius: "var(--radius-small)",
cursor: "pointer",
},
".cm-diffMoveLink:hover": { background: "var(--bg-hover)" },
".cm-diffMoveLink:focus-visible": { outline: "2px solid var(--accent)", outlineOffset: "2px" },
});
export const movedCodeHighlights = (words: boolean) => [
chunkDecorations((view) => decorations(view, words)),
EditorView.baseTheme({
".cm-diffMoved": { boxShadow: "inset 3px 0 0 color-mix(in srgb, var(--accent) 70%, transparent)" },
".cm-diffMoveEdit-deleted": { backgroundColor: "color-mix(in srgb, var(--diff-deleted) 85%, transparent)" },
".cm-diffMoveEdit-inserted": { backgroundColor: "color-mix(in srgb, var(--diff-inserted) 85%, transparent)" },
".cm-diffMoveLink": {
marginLeft: "12px",
padding: "0 4px",
fontFamily: "var(--font-ui)",
fontSize: "var(--fs-small)",
color: "var(--link)",
background: "var(--bg-app)",
border: "1px solid var(--border)",
borderRadius: "var(--radius-small)",
cursor: "pointer",
},
".cm-diffMoveLink:hover": { background: "var(--bg-hover)" },
".cm-diffMoveLink:focus-visible": { outline: "2px solid var(--accent)", outlineOffset: "2px" },
}),
movedCodeTheme,
];