Treat file without extension as text + more syntax highlighted mapping (#708)

This commit is contained in:
Tan Nhu 2023-10-20 20:27:44 +00:00 committed by Harness
parent 16a6a73e80
commit 3c83ecb0df
2 changed files with 17 additions and 4 deletions

View File

@ -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 = [

View File

@ -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<string, string> = {
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'