fix(editor): stop adding theme rules for every editor tab and notebook cell (#5995)

breakpointGutter, inlineBlame, indexedMarkers and the notebook CellEditor
built EditorView.theme / baseTheme inside their factories, so every editor or
notebook cell mounted a new style module whose rules CodeMirror never removes
(+12 rules per file editor, +1.4k while scrolling a 100-cell notebook). The
four themes are now module constants, like the other editor themes; the font
theme in setup.ts is already cached per key.

Co-authored-by: audichuang <[email protected]>
Цей коміт міститься в:
audichuang authored and GitHub committed 2026-11-26 12:51:14 +08:00
1 джерело 5886e055b4
коміт daee26e680
6 files changed
+90 -26

No files matched your search

+6 -7
Переглянути файл
@@ -136,6 +136,11 @@ function inBreakpointArea(e: MouseEvent): boolean {
return t.classList.contains("cm-gutterElement") && t.childElementCount === 0;
}
/** Created once: every `EditorView.theme` call mounts new CSS rules into the document. */
const BREAKPOINT_GUTTER_THEME = EditorView.theme({
".cm-lineNumbers .cm-gutterElement": { cursor: "default" },
});
export function breakpointGutter(ctx: EditorDocContext): Extension {
const reason = classFileBreakpointReason(ctx.path);
if (reason) {
@@ -311,11 +316,5 @@ export function breakpointGutter(ctx: EditorDocContext): Extension {
},
);
return [
field,
plugin,
EditorView.theme({
".cm-lineNumbers .cm-gutterElement": { cursor: "default" },
}),
];
return [field, plugin, BREAKPOINT_GUTTER_THEME];
}