Файли
openidea/src/features/plugins/editorContext.ts
T
Deng Liuтаdengliu 79accd1311 perf(settings): split Settings and auxiliary window boot out of the Workbench module (#4044)
Native auxiliary windows (settings, comparison, diff, deployment) all booted src/main.tsx, which statically imported the Workbench and every workbench feature (CodeMirror, xterm, editor extensions) even when the Settings window rendered none of them. main.tsx is now a small window-kind router with one boot module per window kind, and the settings pages, core plugin points and plugin theme runtime are registered from editor-free modules, so the Settings window loads no Workbench, @codemirror, @xterm or @/editor modules (about 57% less JS and a third less heap per Settings window). A static test keeps the Settings boot isolated.

Part of #3942

Co-authored-by: dengliu <[email protected]>
2026-11-18 18:32:14 +08:00

24 рядки
811 B
TypeScript

/**
* The editor a plugin call is about: the window's active text editor, as
* commands get it (path, language, selections in line / UTF-16 column). Tool
* windows' renders and events carry it too, so their buttons act on what the
* user is editing; a custom editor's calls carry its own document instead.
*
* Provided by the workbench (`points.tsx`) so editor-free windows (Settings)
* do not pull in `@/editor/api` and CodeMirror.
*/
import type { PluginEditor } from "@/bindings";
let provider: (() => PluginEditor | null) | null = null;
export function providePluginEditorContext(fn: () => PluginEditor | null): () => void {
provider = fn;
return () => {
if (provider === fn) provider = null;
};
}
export function editorContext(): PluginEditor | null {
return provider?.() ?? null;
}