fix(editor): map .cts/.mts to the typescript language id (#11294)
* fix(editor): map .cts/.mts to the typescript language id The comment above EXT_TO_LANGUAGE already documents that Monaco maps .tsx/.cts/.mts onto the typescript language id, but only .tsx was in the table, so .cts/.mts files opened as plaintext. * fix(mobile): map cts and mts to typescript --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
parent
6f3845baa4
commit
7ba433209c
|
|
@ -10,6 +10,8 @@ function extname(filePath: string): string {
|
|||
const EXT_TO_LANGUAGE: Record<string, string> = {
|
||||
'.ts': 'typescript',
|
||||
'.tsx': 'typescript',
|
||||
'.cts': 'typescript',
|
||||
'.mts': 'typescript',
|
||||
'.js': 'javascript',
|
||||
'.jsx': 'javascript',
|
||||
'.mjs': 'javascript',
|
||||
|
|
|
|||
|
|
@ -11,9 +11,12 @@ import type { MobileDiffLine } from './mobile-diff-lines'
|
|||
describe('mobile file syntax highlighting', () => {
|
||||
it('detects common source languages from file paths', () => {
|
||||
expect(detectMobileFileLanguage('src/App.tsx')).toBe('typescript')
|
||||
expect(detectMobileFileLanguage('config/vitest.config.mts')).toBe('typescript')
|
||||
expect(detectMobileFileLanguage('C:\\repo\\scripts\\postinstall.CTS')).toBe('typescript')
|
||||
expect(detectMobileFileLanguage('scripts/deploy.sh')).toBe('shell')
|
||||
expect(detectMobileFileLanguage('Dockerfile')).toBe('dockerfile')
|
||||
expect(resolveMobileSyntaxLanguage('src/App.tsx')).toBe('typescript')
|
||||
expect(resolveMobileSyntaxLanguage('worktrees/feature/build.cts')).toBe('typescript')
|
||||
expect(resolveMobileSyntaxLanguage('Dockerfile')).toBe('plaintext')
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,18 @@ describe('detectLanguage', () => {
|
|||
expect(detectLanguage('C:\\Users\\alice\\.codex\\LOG.JSONL')).toBe('jsonl')
|
||||
})
|
||||
|
||||
it('maps .cts/.mts files to the Monaco built-in typescript language id (case-insensitive)', () => {
|
||||
expect(detectLanguage('config/vitest.config.mts')).toBe('typescript')
|
||||
expect(detectLanguage('scripts/postinstall.cts')).toBe('typescript')
|
||||
expect(detectLanguage('types/global.d.mts')).toBe('typescript')
|
||||
expect(detectLanguage('C:\\repo\\config\\BUILD.MTS')).toBe('typescript')
|
||||
})
|
||||
|
||||
it('keeps .mjs/.cjs on the Monaco built-in javascript language id', () => {
|
||||
expect(detectLanguage('scripts/build.mjs')).toBe('javascript')
|
||||
expect(detectLanguage('scripts/legacy.cjs')).toBe('javascript')
|
||||
})
|
||||
|
||||
it('keeps .json/.jsonc on the built-in json language and unknown on plaintext', () => {
|
||||
expect(detectLanguage('config/settings.json')).toBe('json')
|
||||
expect(detectLanguage('config/tsconfig.jsonc')).toBe('json')
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ const EXT_TO_LANGUAGE: Record<string, string> = {
|
|||
// is what gives .tsx/.jsx files syntax highlighting in the editor.
|
||||
'.ts': 'typescript',
|
||||
'.tsx': 'typescript',
|
||||
'.cts': 'typescript',
|
||||
'.mts': 'typescript',
|
||||
'.js': 'javascript',
|
||||
'.jsx': 'javascript',
|
||||
'.mjs': 'javascript',
|
||||
|
|
|
|||
Loading…
Reference in New Issue