From 241a7b3b9bcf6f06621b9eb94ca2119517802d81 Mon Sep 17 00:00:00 2001 From: lihongyuan99 <64824864+lihongyuan99@users.noreply.github.com> Date: Thu, 1 Oct 2026 09:58:23 +0800 Subject: [PATCH] fix(frontend): key the Julia entry of extensionMap by its extension (#6130) extensionMap is keyed by extension and valued by language, but the Julia row was written backwards as `julia: "jl"`. checkCodeFile tests membership with `extension in extensionMap`, so ".jl" never matched and a Julia artifact was not a code file at all, while ".julia" resolved to a language named "jl". Add both `jl: "julia"` and `julia: "julia"`, the same pair form the map already uses for haskell/hs and elixir/ex, so no extension that classified before stops classifying. --- frontend/src/core/utils/files.tsx | 3 +- frontend/tests/unit/core/utils/files.test.ts | 31 +++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/frontend/src/core/utils/files.tsx b/frontend/src/core/utils/files.tsx index 4c4d6ca116..97e0574109 100644 --- a/frontend/src/core/utils/files.tsx +++ b/frontend/src/core/utils/files.tsx @@ -109,7 +109,8 @@ const extensionMap: Record = { lua: "lua", r: "r", matlab: "matlab", - julia: "jl", + julia: "julia", + jl: "julia", elm: "elm", haskell: "haskell", hs: "haskell", diff --git a/frontend/tests/unit/core/utils/files.test.ts b/frontend/tests/unit/core/utils/files.test.ts index f10aa44ad8..97a9d2a0d8 100644 --- a/frontend/tests/unit/core/utils/files.test.ts +++ b/frontend/tests/unit/core/utils/files.test.ts @@ -1,7 +1,11 @@ import { expect, test } from "@rstest/core"; import { FilePlayIcon, FileTextIcon, ImageIcon } from "lucide-react"; -import { canBrowserPreviewFile, getFileIcon } from "@/core/utils/files"; +import { + canBrowserPreviewFile, + checkCodeFile, + getFileIcon, +} from "@/core/utils/files"; test.each([ ["animation.apng", ImageIcon], @@ -15,3 +19,28 @@ test.each([ test("keeps the document icon for an unknown extension", () => { expect(getFileIcon("data.unknown").type).toBe(FileTextIcon); }); + +// `extensionMap` maps a file extension to a language name. Both halves of that +// direction matter: `checkCodeFile` tests extension membership, and the language +// is what the editor and previewers receive. +test("resolves a language from its extension", () => { + expect(checkCodeFile("script.hs")).toEqual({ + isCodeFile: true, + language: "haskell", + }); + expect(checkCodeFile("deploy.ex")).toEqual({ + isCodeFile: true, + language: "elixir", + }); + expect(checkCodeFile("analysis.jl")).toEqual({ + isCodeFile: true, + language: "julia", + }); +}); + +test("values the language name, never the extension it came from", () => { + expect(checkCodeFile("notes.julia")).toEqual({ + isCodeFile: true, + language: "julia", + }); +});