Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public struct LanguageCatalog: Sendable {
"go": "go",
"rs": "rust",
"rb": "ruby",
"ex": "elixir",
"exs": "elixir",
"erl": "erlang",
"hrl": "erlang",
"java": "java",
"kt": "kotlin",
"kts": "kotlin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ struct LanguageCatalogTests {
#expect(catalog.language(forExtension: ".py") == "python")
}

@Test("Maps BEAM source extensions to highlight.js ids")
func mapsBeamExtensions() {
#expect(catalog.language(forExtension: "ex") == "elixir")
#expect(catalog.language(forExtension: "exs") == "elixir")
#expect(catalog.language(forExtension: "erl") == "erlang")
#expect(catalog.language(forExtension: "hrl") == "erlang")
}

@Test("Unknown extensions return nil")
func unknownExtensionIsNil() {
#expect(catalog.language(forExtension: "bin") == nil)
Expand Down
3 changes: 2 additions & 1 deletion Sources/Panels/FilePreviewPanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,8 @@ enum FilePreviewKindResolver {

private static let textExtensions: Set<String> = [
"bash", "c", "cc", "cfg", "conf", "cpp", "cs", "css", "csv", "cts", "env",
"fish", "go", "h", "hpp", "htm", "html", "ini", "java", "js", "json",
"erl", "ex", "exs", "fish", "go", "h", "hpp", "hrl", "htm", "html", "ini",
"java", "js", "json",
"jsx", "kt", "log", "m", "markdown", "md", "mdx", "mm", "mts", "plist",
"py", "rb", "rs", "sh", "sql", "swift", "toml", "ts", "tsx", "tsv", "txt",
"xml", "yaml", "yml", "zsh"
Expand Down
19 changes: 19 additions & 0 deletions cmuxTests/FilePreviewKindResolverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,25 @@ struct FilePreviewKindResolverTests {
}
}

@Test("Elixir and Erlang source files route directly to text preview")
func beamSourceFilesRouteDirectlyToTextPreview() throws {
// .exs collides with the Logic sampler UTI (com.apple.logic.exs), which
// conforms to audiovisualContent and would otherwise open as media.
for fileExtension in ["ex", "exs", "erl", "hrl"] {
let url = try temporaryFile(
extension: fileExtension,
contents: "defmodule Greeter do\n def hello, do: :world\nend\n"
)
defer { try? FileManager.default.removeItem(at: url) }

#expect(
FilePreviewKindResolver.initialMode(for: url) == .text,
"Expected .\(fileExtension) to avoid the QuickLook/media backend before async resolution."
)
#expect(FilePreviewKindResolver.mode(for: url) == .text)
}
}

@Test("Movie file extensions keep media preview")
func movieFileExtensionsKeepMediaPreview() throws {
for fileExtension in ["mov", "mp4"] {
Expand Down
Loading