Compare commits

...

3 Commits

Author SHA1 Message Date
b2ba7858cf Merge branch 'main' into paultag/remove-add 2024-07-23 04:55:33 -04:00
cfeb4f4575 tweak the logic 2024-07-23 04:51:30 -04:00
0b06e7cd17 Remove old addDiagnostics function
Signed-off-by: Paul Tagliamonte <paul@zoo.dev>
2024-07-22 16:45:00 -04:00
2 changed files with 9 additions and 26 deletions

View File

@ -21,13 +21,10 @@ export const modelingMachineEvent = modelingMachineAnnotation.of(true)
const setDiagnosticsAnnotation = Annotation.define<boolean>()
export const setDiagnosticsEvent = setDiagnosticsAnnotation.of(true)
function diagnosticIsEqual(d1: Diagnostic, d2: Diagnostic): boolean {
return d1.from === d2.from && d1.to === d2.to && d1.message === d2.message
}
export default class EditorManager {
private _editorView: EditorView | null = null
private _copilotEnabled: boolean = true
private _diagnostics: Diagnostic[] = []
private _isShiftDown: boolean = false
private _selectionRanges: Selections = {
@ -118,6 +115,14 @@ export default class EditorManager {
this.setDiagnostics([])
}
addDiagnostics(diagnostics: Diagnostic[]): void {
if (!this._editorView) return
diagnostics.forEach((diagnostic) => {
this._diagnostics.push(diagnostic)
})
this.setDiagnostics(this._diagnostics)
}
setDiagnostics(diagnostics: Diagnostic[]): void {
if (!this._editorView) return
@ -131,26 +136,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

@ -217,7 +217,6 @@ export class KclManager {
ast,
engineCommandManager: this.engineCommandManager,
})
editorManager.addDiagnostics(await lintAst({ ast: ast }))
sceneInfra.modelingSend({ type: 'code edit during sketch' })
@ -298,7 +297,6 @@ export class KclManager {
engineCommandManager: this.engineCommandManager,
useFakeExecutor: true,
})
editorManager.addDiagnostics(await lintAst({ ast: ast }))
this._logs = logs