Files
openidea/src/platform/clientSettings.ts
T
l0ng-ai a03923f744 fix(fonts): editor popups and consoles follow the configured fonts (#3835)
- Completion, parameter info and hover docs render in a tooltip container
  outside the editor, which carries its theme classes but not its inline
  style, so they used the default mono font at 13px. The editor font
  variables are now also provided as a theme; completion rows grow with
  the font size.
- The Run and Debug consoles use the terminal's weights (the editor's main
  and bold weights when the terminal follows the editor font).
- "Show only monospaced fonts" is a setting shared by Editor › Font and
  Tools › Terminal instead of resetting every time the page opens.

Fixes #3621
2026-11-17 04:09:12 +08:00

136 lines
4.2 KiB
TypeScript

/** Settings model ownership: these UI preferences belong to the client, including their descendants.
* Mixed sections deliberately list individual keys so project/tooling settings stay on the host.
* Keep this module dependency-free: the transport also consumes this metadata.
*/
export const CLIENT_SETTINGS_KEYS = [
"keymap",
"keymapOverrides",
"customKeymaps",
"appearance",
"notifications",
"general.reopenLastProject",
"general.confirmExit",
"general.closeWithoutWelcome",
"general.closeTabsWithWindow",
"general.openProjectIn",
"general.updateSource",
"general.autoCheckUpdates",
"general.showWhatsNewAfterUpdate",
"general.lastRunVersion",
"general.dateFormat",
"editor.fontFamily",
"editor.fontSize",
"editor.lineHeight",
"editor.ligatures",
"editor.onlyMonospacedFonts",
"editor.fallbackFont",
"editor.fontWeight",
"editor.boldFontWeight",
"editor.colorScheme",
"editor.colorOverrides",
"editor.customSchemes",
"editor.semanticHighlighting",
"editor.docstringFormat",
"editor.rainbowBrackets",
"editor.rainbowBracketKinds",
"editor.rainbowBracketColors",
"editor.softWrap",
"editor.showWhitespace",
"editor.inlayHints",
"editor.stickyScroll",
"editor.appearance",
"editor.breadcrumbs",
"editor.folding",
"editor.tabs",
"editor.codeEditing",
"editor.inlay",
"editor.gutterIconsDisabled",
"editor.showGutterIcons",
"editor.general.wheelZoom",
"editor.general.wheelZoomScope",
"editor.general.dragAndDrop",
"editor.general.caretScroll",
"editor.general.softWrapFiles",
"editor.general.softWrapIndent",
"editor.general.scrollPastEnd",
"editor.general.richTextCopy",
"editor.codeStyle.visualGuides",
"terminal.tabName",
"terminal.audibleBell",
"terminal.closeOnExit",
"terminal.mouseReporting",
"terminal.copyOnSelection",
"terminal.pasteOnMiddleClick",
"terminal.overrideIdeShortcuts",
"terminal.highlightHyperlinks",
"terminal.optionAsMeta",
"terminal.escapeToEditor",
"terminal.cursorShape",
"terminal.cursorBlink",
"terminal.useEditorFont",
"terminal.fontFamily",
"terminal.fontSize",
"terminal.lineHeight",
"terminal.fallbackFontFamily",
"terminal.columnWidth",
"console.softWrap",
"console.foldPatterns",
"console.logColors",
"debugger.showOnBreakpoint",
"debugger.focusAppOnBreakpoint",
"debugger.hideOnTermination",
"debugger.variablesOnBreakpoint",
"debugger.runToCursorInlay",
"debugger.inlineValues",
"debugger.sortValues",
"debugger.valueTooltip",
"debugger.valueTooltipOnSelection",
"debugger.valueTooltipDelay",
"run.confirmRerun",
"run.confirmTerminate",
"run.showOnStart",
"run.pinTabs",
"externalDiff",
"vcs.showDirtyDirectories",
"vcs.git.inlineBlame",
"vcs.git.inlineBlameClickable",
"vcs.git.showBranchInProjectView",
"vcs.git.showPushDialog",
"vcs.git.pushDialogOnlyProtected",
"vcs.git.combineStashAndShelf",
"vcs.git.stagingArea",
"vcs.commit.nonModal",
"vcs.commit.doubleClickOpensDiff",
"vcs.commit.showRightMargin",
"agents.showContextUsage",
"agents.showWorkTime",
"agents.showUsageLimits",
"agents.showCost",
"agents.foldTurns",
"agents.smoothText",
"agents.fitWindowWidth",
"agents.thinking",
"agents.toolCalls",
"agents.expandToolOutput",
"agents.sendWith",
"agents.whileRunning",
] as const;
export function isClientSetting(key: string): boolean {
return CLIENT_SETTINGS_KEYS.some((root) => key === root || key.startsWith(`${root}.`));
}
/** Overlay from local globals, never from the local window's project layer. Missing client keys
* also replace remote values, so older local settings fall back to client defaults.
*/
export function overlayClientSettings<T>(remote: T, local: unknown): T {
const object = (value: unknown): Record<string, unknown> =>
value && typeof value === "object" ? (value as Record<string, unknown>) : {};
const copy = (target: unknown, source: unknown, path: string[]): unknown => {
const [head, ...tail] = path;
const value = object(source)[head!];
return { ...object(target), [head!]: tail.length ? copy(object(target)[head!], value, tail) : value };
};
return CLIENT_SETTINGS_KEYS.reduce((settings, key) => copy(settings, local, key.split(".")) as T, remote);
}