mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 00:57:45 +00:00
fix(editor): highlight Justfile recipes and mobile HCL assignments (#35573)
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
@@ -9,6 +9,43 @@ import {
|
||||
import type { MobileDiffLine } from './mobile-diff-lines'
|
||||
|
||||
describe('mobile file syntax highlighting', () => {
|
||||
it.each(['justfile', 'Justfile', '.justfile', 'tasks.just', 'C:\\repo\\TASKS.JUST'])(
|
||||
'highlights shell recipes in %s',
|
||||
(filePath) => {
|
||||
const source = '# Build recipe\nbuild:\n echo "ready"\n'
|
||||
const result = highlightMobileCode(source, resolveMobileSyntaxLanguage(filePath))
|
||||
expect(result.highlighted).toBe(true)
|
||||
expect(result.segments.map((segment) => segment.text).join('')).toBe(source)
|
||||
expect(result.segments).toEqual(
|
||||
expect.arrayContaining([
|
||||
{ text: '# Build recipe', kind: 'comment' },
|
||||
{ text: '"ready"', kind: 'string' }
|
||||
])
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
it.each(['terraform.tfvars', 'C:\\repo\\PROD.TFVARS', 'main.tf', 'config.hcl'])(
|
||||
'highlights HCL assignments in %s',
|
||||
(filePath) => {
|
||||
const source = '# Deployment\nregion = "us-west-2"\ncount = 3\n'
|
||||
const language = resolveMobileSyntaxLanguage(filePath)
|
||||
const result = highlightMobileCode(source, language)
|
||||
expect(result.highlighted).toBe(true)
|
||||
expect(result.segments.map((segment) => segment.text).join('')).toBe(source)
|
||||
expect(result.segments).toEqual(
|
||||
expect.arrayContaining([
|
||||
{ text: '# Deployment', kind: 'comment' },
|
||||
{ text: 'region', kind: 'variable' },
|
||||
{ text: '"us-west-2"', kind: 'string' }
|
||||
])
|
||||
)
|
||||
const [line] = highlightMobileDiffLines([{ text: 'region = "us-west-2"' }], language)
|
||||
expect(line?.highlighted).toBe(true)
|
||||
expect(line?.segments).toContainEqual({ text: '"us-west-2"', kind: 'string' })
|
||||
}
|
||||
)
|
||||
|
||||
it.each([
|
||||
['.env', 'dotenv'],
|
||||
['.env.local', 'dotenv'],
|
||||
|
||||
@@ -55,7 +55,9 @@ const LANGUAGE_ALIASES = new Map([
|
||||
['glimmer-js', 'javascript'],
|
||||
['glimmer-ts', 'typescript'],
|
||||
// lowlight has no dotenv grammar; ini covers KEY=value and # comments.
|
||||
['dotenv', 'ini']
|
||||
['dotenv', 'ini'],
|
||||
// HCL assignments, strings and comments use the bundled ini grammar on mobile.
|
||||
['hcl', 'ini']
|
||||
])
|
||||
|
||||
export function resolveMobileSyntaxLanguage(filePath: string, preferredLanguage?: string): string {
|
||||
|
||||
@@ -73,6 +73,7 @@ const EXT_TO_LANGUAGE: Record<string, string> = {
|
||||
'.php': 'php',
|
||||
'.swift': 'swift',
|
||||
'.sh': 'shell',
|
||||
'.just': 'shell',
|
||||
'.bash': 'shell',
|
||||
'.zsh': 'shell',
|
||||
'.fish': 'shell',
|
||||
@@ -135,6 +136,8 @@ const FILENAME_TO_LANGUAGE: Record<string, string> = {
|
||||
Dockerfile: 'dockerfile',
|
||||
Jenkinsfile: 'groovy',
|
||||
Makefile: 'makefile',
|
||||
Justfile: 'shell',
|
||||
'.justfile': 'shell',
|
||||
'CMakeLists.txt': 'cmake',
|
||||
'.gitignore': 'ini',
|
||||
'.gitattributes': 'ini',
|
||||
|
||||
Reference in New Issue
Block a user