Файли
openidea/e2e/cppNamespaceStyle.fixture.ts
T
txdywmwddhxs 2413cc4b43 fix(editor): preserve C++ namespace colors for library symbols (#6133)
clangd marks std and other standard-library namespaces with the defaultLibrary modifier, so the generic builtin (Predefined symbol) class overrode the Namespace colour. A C++ semantic hook drops the builtin class for namespace tokens only; other symbol kinds, modifiers and languages keep their styling.

Fixes #6123

Co-authored-by: txdywmwddhxs <[email protected]>
2026-11-26 18:02:58 +08:00

36 рядки
1.1 KiB
TypeScript

import { EditorView } from "@codemirror/view";
import { commands } from "../src/platform/ipc";
import { setInvokeRoute } from "../src/platform/tauriCore";
import { schemeCss } from "../src/platform/colorScheme";
import { lspDoc } from "../src/editor/lsp/lsp";
import { semanticExtension } from "../src/editor/lsp/semantic";
import { lspTheme } from "../src/editor/lsp/theme";
setInvokeRoute(() => null);
commands.lspSemanticTokens = async () => ({
status: "ok",
data: {
tokenTypes: ["namespace"],
tokenModifiers: ["defaultLibrary", "globalScope"],
data: [0, 0, 7, 0, 2, 1, 0, 3, 0, 3],
},
});
const mode = new URLSearchParams(location.search).has("light") ? "light" : "dark";
const style = document.createElement("style");
style.textContent = schemeCss(mode, {
[mode]: {
packageReference: { foreground: "#446688" },
predefined: { foreground: "#cc5500" },
},
});
document.head.append(style);
new EditorView({
parent: document.body,
doc: "example::hello();\nstd::cout << 1;",
extensions: [
lspTheme,
lspDoc.of({ doc: 1, path: "demo.cpp", language: "cpp", uiMode: "C++", readOnly: false }),
semanticExtension(),
],
});