Sketch mode more tolerant to syntax errors (#4056)

* add fix

* add test

* typos

* clean up
This commit is contained in:
Kurt Hutten
2024-10-02 13:15:40 +10:00
committed by GitHub
parent cd91774881
commit 47e472e984
7 changed files with 134 additions and 31 deletions

View File

@ -43,6 +43,7 @@ export class KclManager {
digest: null,
}
private _programMemory: ProgramMemory = ProgramMemory.empty()
lastSuccessfulProgramMemory: ProgramMemory = ProgramMemory.empty()
private _logs: string[] = []
private _lints: Diagnostic[] = []
private _kclErrors: KCLError[] = []
@ -297,6 +298,9 @@ export class KclManager {
// Do not add the errors since the program was interrupted and the error is not a real KCL error
this.addKclErrors(isInterrupted ? [] : errors)
this.programMemory = programMemory
if (!errors.length) {
this.lastSuccessfulProgramMemory = programMemory
}
this.ast = { ...ast }
this._executeCallback()
this.engineCommandManager.addCommandLog({
@ -342,6 +346,9 @@ export class KclManager {
this._logs = logs
this._kclErrors = errors
this._programMemory = programMemory
if (!errors.length) {
this.lastSuccessfulProgramMemory = programMemory
}
if (updates !== 'artifactRanges') return
// TODO the below seems like a work around, I wish there's a comment explaining exactly what