mirror of
https://github.com/harness/drone.git
synced 2025-05-31 11:43:15 +00:00
fix: [code-1358]: add highlight support for terraform files in gitblame (#987)
This commit is contained in:
parent
f39852dc62
commit
0246d1bc48
@ -23,6 +23,7 @@ import type { ViewUpdate } from '@codemirror/view'
|
||||
import type { Text } from '@codemirror/state'
|
||||
import { languages } from '@codemirror/language-data'
|
||||
import { markdown } from '@codemirror/lang-markdown'
|
||||
import { java } from '@codemirror/lang-java'
|
||||
import { EditorView, keymap, placeholder as placeholderExtension } from '@codemirror/view'
|
||||
import { Compartment, EditorState, Extension } from '@codemirror/state'
|
||||
import { color } from '@uiw/codemirror-extensions-color'
|
||||
@ -205,6 +206,25 @@ export const Editor = React.memo(function CodeMirrorReactEditor({
|
||||
})
|
||||
}
|
||||
}, [filename, forMarkdown, view, languageConfig, markdownLanguageSupport])
|
||||
useEffect(() => {
|
||||
if (filename) {
|
||||
let languageSupport
|
||||
if (
|
||||
filename.endsWith('.tf') ||
|
||||
filename.endsWith('.hcl') ||
|
||||
filename.endsWith('.tfstate') ||
|
||||
filename.endsWith('.tfvars')
|
||||
) {
|
||||
languageSupport = java()
|
||||
}
|
||||
// Add other file extensions and their corresponding language modes
|
||||
if (languageSupport) {
|
||||
view.current?.dispatch({
|
||||
effects: languageConfig.reconfigure(languageSupport)
|
||||
})
|
||||
}
|
||||
}
|
||||
}, [filename, view, languageConfig, markdownLanguageSupport])
|
||||
const handleUploadCallback = (file: File) => {
|
||||
if (!inGitBlame) {
|
||||
setFile(file)
|
||||
|
@ -483,6 +483,7 @@ const TextExtensions = [
|
||||
'alpine',
|
||||
'tf',
|
||||
'tfvars',
|
||||
'tfstate',
|
||||
'hcl'
|
||||
]
|
||||
|
||||
|
@ -471,7 +471,8 @@ const EXTENSION_TO_LANG: Record<string, string> = {
|
||||
tsx: 'typescript',
|
||||
tf: 'hcl',
|
||||
tfvars: 'hcl',
|
||||
workspace: 'python'
|
||||
workspace: 'python',
|
||||
tfstate: 'hcl'
|
||||
}
|
||||
|
||||
export const PLAIN_TEXT = 'plaintext'
|
||||
|
Loading…
x
Reference in New Issue
Block a user