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

+16 -13
Переглянути файл
@@ -83,6 +83,21 @@ export function markersOf(
);
}
/** Created once: every `EditorView.baseTheme` call mounts new CSS rules into the document. */
const INDEXED_MARKERS_THEME = EditorView.baseTheme({
".cm-plugin-mapping-button": {
border: "none",
padding: "0 2px",
background: "transparent",
color: "inherit",
cursor: "pointer",
height: "100%",
display: "flex",
alignItems: "center",
},
".cm-plugin-mapping-button:focus-visible": { outline: "1px solid var(--accent)" },
});
export function indexedMarkers(path: string): Extension {
return [
markersField,
@@ -92,19 +107,7 @@ export function indexedMarkers(path: string): Extension {
markers: (view) => view.state.field(markersField),
reserve: (state) => state.field(markersField).size > 0,
}),
EditorView.baseTheme({
".cm-plugin-mapping-button": {
border: "none",
padding: "0 2px",
background: "transparent",
color: "inherit",
cursor: "pointer",
height: "100%",
display: "flex",
alignItems: "center",
},
".cm-plugin-mapping-button:focus-visible": { outline: "1px solid var(--accent)" },
}),
INDEXED_MARKERS_THEME,
ViewPlugin.fromClass(
class {
last: FileMarkers | undefined;