Remove old addDiagnostics function

Signed-off-by: Paul Tagliamonte <paul@zoo.dev>
This commit is contained in:
Paul Tagliamonte
2024-07-22 16:45:00 -04:00
parent 397839da84
commit 0b06e7cd17
2 changed files with 9 additions and 23 deletions

View File

@ -131,26 +131,6 @@ export default class EditorManager {
})
}
addDiagnostics(diagnostics: Diagnostic[]): void {
if (!this._editorView) return
forEachDiagnostic(this._editorView.state, function (diag) {
diagnostics.push(diag)
})
const uniqueDiagnostics = new Set<Diagnostic>()
diagnostics.forEach((diagnostic) => {
for (const knownDiagnostic of uniqueDiagnostics.values()) {
if (diagnosticIsEqual(diagnostic, knownDiagnostic)) {
return
}
}
uniqueDiagnostics.add(diagnostic)
})
this.setDiagnostics([...uniqueDiagnostics])
}
undo() {
if (this._editorView) {
undo(this._editorView)

View File

@ -100,7 +100,7 @@ export class KclManager {
set kclErrors(kclErrors) {
this._kclErrors = kclErrors
let diagnostics = kclErrorsToDiagnostics(kclErrors)
editorManager.addDiagnostics(diagnostics)
editorManager.setDiagnostics(diagnostics)
this._kclErrorsCallBack(kclErrors)
}
@ -223,7 +223,10 @@ export class KclManager {
engineCommandManager: this.engineCommandManager,
})
editorManager.addDiagnostics(await lintAst({ ast: ast }))
const lints = await lintAst({ ast: ast })
if (lints) {
editorManager.setDiagnostics(lints)
}
sceneInfra.modelingSend({ type: 'code edit during sketch' })
defaultSelectionFilter(programMemory, this.engineCommandManager)
@ -304,7 +307,10 @@ export class KclManager {
useFakeExecutor: true,
})
editorManager.addDiagnostics(await lintAst({ ast: ast }))
const lints = await lintAst({ ast: ast })
if (lints) {
editorManager.setDiagnostics(lints)
}
this._logs = logs
this._kclErrors = errors