Skip to content

Commit 6a07170

Browse files
author
lukaw3d
committed
Only show yaml validation errors if code is editable
Readonly machine logs aren't valid yaml, so don't show validation errors there.
1 parent df2ecd5 commit 6a07170

1 file changed

Lines changed: 21 additions & 19 deletions

File tree

src/components/CodeDisplay/index.tsx

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -109,27 +109,29 @@ export const CodeDisplay: FC<CodeDisplayProps> = ({ data, className, readOnly =
109109
const model = editorRef.current.getModel()
110110
if (!model) return
111111

112-
const markers: monaco.editor.IMarkerData[] = []
113-
114-
try {
115-
yaml.parse(value)
116-
} catch (e) {
117-
const yamlError = e as { message: string; linePos: { line: number; col: number }[] }
118-
if (yamlError.linePos && yamlError.linePos.length > 0) {
119-
const line = yamlError.linePos[0].line
120-
const column = yamlError.linePos[0].col
121-
markers.push({
122-
startLineNumber: line,
123-
endLineNumber: line,
124-
startColumn: column,
125-
endColumn: model.getLineMaxColumn(line),
126-
message: yamlError.message,
127-
severity: monacoInstance.MarkerSeverity.Error,
128-
})
112+
if (!readOnly) {
113+
const markers: monaco.editor.IMarkerData[] = []
114+
115+
try {
116+
yaml.parse(value)
117+
} catch (e) {
118+
const yamlError = e as { message: string; linePos: { line: number; col: number }[] }
119+
if (yamlError.linePos && yamlError.linePos.length > 0) {
120+
const line = yamlError.linePos[0].line
121+
const column = yamlError.linePos[0].col
122+
markers.push({
123+
startLineNumber: line,
124+
endLineNumber: line,
125+
startColumn: column,
126+
endColumn: model.getLineMaxColumn(line),
127+
message: yamlError.message,
128+
severity: monacoInstance.MarkerSeverity.Error,
129+
})
130+
}
129131
}
130-
}
131132

132-
monacoInstance.editor.setModelMarkers(model, 'yaml-validator', markers)
133+
monacoInstance.editor.setModelMarkers(model, 'yaml-validator', markers)
134+
}
133135

134136
highlightErrorLogs(value)
135137

0 commit comments

Comments
 (0)