From 3c83ecb0df47d26243ab7d2d7d1485bb1091e90e Mon Sep 17 00:00:00 2001 From: Tan Nhu Date: Fri, 20 Oct 2023 20:27:44 +0000 Subject: [PATCH] Treat file without extension as text + more syntax highlighted mapping (#708) --- web/src/utils/FileUtils.ts | 11 +++++++++-- web/src/utils/Utils.ts | 10 ++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/web/src/utils/FileUtils.ts b/web/src/utils/FileUtils.ts index e821de212..60c5c6db5 100644 --- a/web/src/utils/FileUtils.ts +++ b/web/src/utils/FileUtils.ts @@ -68,8 +68,12 @@ export function useFileContentViewerDecision({ SpecialTextFiles.find(name => name.toLowerCase() === filename?.toLowerCase()) || TextExtensions.includes(extension.toLowerCase()) || isSymlink || - isSubmodule + isSubmodule || + !extension || + extension === filename || + '.' + extension === filename ) + const category = isMarkdown ? FileCategory.MARKDOWN : isSVG @@ -155,6 +159,7 @@ const TextExtensions = [ 'bat', 'bbcolors', 'bcp', + 'bazel', 'bdsgroup', 'bdsproj', 'bib', @@ -473,7 +478,9 @@ const TextExtensions = [ 'uot', 'ahk', 'asciidoc', - 'slk' + 'slk', + 'env', + 'alpine' ] const SpecialTextFiles = [ diff --git a/web/src/utils/Utils.ts b/web/src/utils/Utils.ts index c07cad88f..db6b538ff 100644 --- a/web/src/utils/Utils.ts +++ b/web/src/utils/Utils.ts @@ -296,14 +296,20 @@ const MONACO_SUPPORTED_LANGUAGES = [ 'yaml' ] +// Some of the below languages are mapped to Monaco's built-in supported languages +// due to their similarity. We'll still need to get native support for them at +// some point. const EXTENSION_TO_LANG: Record = { tsx: 'typescript', jsx: 'typescript', cc: 'cpp', env: 'shell', - Makefile: 'shell', + makefile: 'shell', gitignore: 'shell', - toml: 'ini' + toml: 'ini', + bazel: 'python', + workspace: 'python', + alpine: 'dockerfile' } export const PLAIN_TEXT = 'plaintext'