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()) || SpecialTextFiles.find(name => name.toLowerCase() === filename?.toLowerCase()) ||
TextExtensions.includes(extension.toLowerCase()) || TextExtensions.includes(extension.toLowerCase()) ||
isSymlink || isSymlink ||
isSubmodule isSubmodule ||
!extension ||
extension === filename ||
'.' + extension === filename
) )
const category = isMarkdown const category = isMarkdown
? FileCategory.MARKDOWN ? FileCategory.MARKDOWN
: isSVG : isSVG
@ -155,6 +159,7 @@ const TextExtensions = [
'bat', 'bat',
'bbcolors', 'bbcolors',
'bcp', 'bcp',
'bazel',
'bdsgroup', 'bdsgroup',
'bdsproj', 'bdsproj',
'bib', 'bib',
@ -473,7 +478,9 @@ const TextExtensions = [
'uot', 'uot',
'ahk', 'ahk',
'asciidoc', 'asciidoc',
'slk' 'slk',
'env',
'alpine'
] ]
const SpecialTextFiles = [ const SpecialTextFiles = [

View File

@ -296,14 +296,20 @@ const MONACO_SUPPORTED_LANGUAGES = [
'yaml' '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> = { const EXTENSION_TO_LANG: Record<string, string> = {
tsx: 'typescript', tsx: 'typescript',
jsx: 'typescript', jsx: 'typescript',
cc: 'cpp', cc: 'cpp',
env: 'shell', env: 'shell',
Makefile: 'shell', makefile: 'shell',
gitignore: 'shell', gitignore: 'shell',
toml: 'ini' toml: 'ini',
bazel: 'python',
workspace: 'python',
alpine: 'dockerfile'
} }
export const PLAIN_TEXT = 'plaintext' export const PLAIN_TEXT = 'plaintext'