fix(coding-agent): highlight dart, nix, and groovy files in read/write views

This commit is contained in:
triagent 2026-10-31 14:43:35 +00:00
parent bb36171aac
commit 7084eec358
2 changed files with 19 additions and 1 deletions

View file

@ -969,6 +969,10 @@ export function getLanguageFromPath(filePath: string): string | undefined {
java: "java",
kt: "kotlin",
swift: "swift",
dart: "dart",
groovy: "groovy",
gradle: "groovy",
nix: "nix",
c: "c",
h: "c",
cpp: "cpp",

View file

@ -1,6 +1,12 @@
import { resetCapabilitiesCache, setCapabilities } from "@earendil-works/pi-tui";
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { getMarkdownTheme, highlightCode, initTheme, theme } from "../src/modes/interactive/theme/theme.ts";
import {
getLanguageFromPath,
getMarkdownTheme,
highlightCode,
initTheme,
theme,
} from "../src/modes/interactive/theme/theme.ts";
import {
highlight,
loadAllHighlightLanguages,
@ -41,6 +47,14 @@ describe("syntax highlight renderer", () => {
expect(supportsLanguage("ada")).toBe(true);
});
it("maps file extensions of eagerly loaded languages to their language", () => {
expect(getLanguageFromPath("lib/main.dart")).toBe("dart");
expect(getLanguageFromPath("flake.nix")).toBe("nix");
expect(getLanguageFromPath("script.groovy")).toBe("groovy");
expect(getLanguageFromPath("build.gradle")).toBe("groovy");
expect(getLanguageFromPath("src/Main.kt")).toBe("kotlin");
});
it("renders highlighted spans with the provided theme", () => {
const rendered = renderHighlightedHtml('<span class="hljs-keyword">const</span> value', {
keyword: (text) => `[keyword:${text}]`,