дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 09:11:10 +02:00
Syntax and semantic token backgrounds no longer cover characters on neighboring lines when the font box is taller than the line height. Token fills now go through the same 1lh-capped inline background as Find and occurrence highlights, with the colour in --openidea-token-bg so semantic roles can override nested syntax fills; an unset fill paints nothing. The background size is a separate declaration, so WebKit without lh support still shows the fill. Co-authored-by: dengliu <[email protected]>
59 рядки
2.1 KiB
TypeScript
59 рядки
2.1 KiB
TypeScript
import { EditorView } from "@codemirror/view";
|
|
import { syntaxHighlighting } from "@codemirror/language";
|
|
import { schemeCss } from "../src/platform/colorScheme";
|
|
import { openideaHighlightStyle } from "../src/editor/core/cm/highlight";
|
|
import { findLanguageDescription, loadSupport } from "../src/editor/core/cm/languages";
|
|
import { syntaxHighlightField, setSyntaxHighlights } from "../src/editor/core/cm/syntaxHighlight";
|
|
import { commands } from "../src/platform/ipc";
|
|
import { setInvokeRoute } from "../src/platform/tauriCore";
|
|
import { lspDoc } from "../src/editor/lsp/lsp";
|
|
import { semanticExtension } from "../src/editor/lsp/semantic";
|
|
import { lspTheme } from "../src/editor/lsp/theme";
|
|
|
|
const semantic = new URLSearchParams(location.search).has("semantic");
|
|
setInvokeRoute(() => null);
|
|
commands.lspSemanticTokens = async () => ({
|
|
status: "ok",
|
|
data: {
|
|
tokenTypes: ["operator", "parameter"],
|
|
tokenModifiers: ["declaration", "modification"],
|
|
data: [1, 4, 5, 0, 1, 1, 10, 6, 1, 2],
|
|
},
|
|
});
|
|
|
|
const style = document.createElement("style");
|
|
style.textContent = schemeCss("dark", {
|
|
dark: {
|
|
"kotlin.functionDeclaration": { foreground: "#557799", background: "#ddeeff", bold: true },
|
|
"kotlin.parameter": { foreground: "#6688aa" },
|
|
},
|
|
});
|
|
document.head.append(style);
|
|
const host = document.createElement("section");
|
|
host.dataset.language = "Kotlin";
|
|
document.body.append(host);
|
|
const support = await loadSupport(findLanguageDescription("Kotlin", "Demo.kt")!);
|
|
const view = new EditorView({
|
|
parent: host,
|
|
doc: "// before\nfun greet(prefix: String) {}\n// after",
|
|
extensions: [
|
|
support!,
|
|
syntaxHighlightField,
|
|
syntaxHighlighting(openideaHighlightStyle),
|
|
...(semantic
|
|
? [
|
|
lspTheme,
|
|
lspDoc.of({ doc: 1, path: "Demo.kt", language: "kotlin", uiMode: "Kotlin", readOnly: false }),
|
|
semanticExtension(),
|
|
]
|
|
: []),
|
|
],
|
|
});
|
|
const start = view.state.doc.line(2).from;
|
|
view.dispatch({
|
|
effects: setSyntaxHighlights.of({
|
|
kinds: ["function", "parameter"],
|
|
data: [start + 4, start + 9, 0, start + 10, start + 16, 1],
|
|
}),
|
|
});
|