diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-3-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-3-Google-Chrome-linux.png index efd71721a76..c0a52375abf 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-3-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-3-Google-Chrome-linux.png differ diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-XZ-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-XZ-1-Google-Chrome-linux.png index ddcb4606274..8240ecba9e6 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-XZ-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-XZ-1-Google-Chrome-linux.png differ diff --git a/src/lang/KclSingleton.ts b/src/lang/KclSingleton.ts index 1f4d91ff381..b2fe7b99b57 100644 --- a/src/lang/KclSingleton.ts +++ b/src/lang/KclSingleton.ts @@ -78,7 +78,7 @@ export class KclManager { private _isExecuting = false private _executeIsStale: ExecuteArgs | null = null private _wasmInitFailed = true - private _hasErrors = false + private _astParseFailed = false private _switchedFiles = false private _fileSettings: KclSettingsAnnotation = {} private _kclVersion: string | undefined = undefined @@ -167,7 +167,7 @@ export class KclManager { } hasErrors(): boolean { - return this._hasErrors + return this._astParseFailed || this._errors.length > 0 } setDiagnosticsForCurrentErrors() { @@ -278,7 +278,7 @@ export class KclManager { private async checkIfSwitchedFilesShouldClear() { // If we were switching files and we hit an error on parse we need to bust // the cache and clear the scene. - if (this._hasErrors && this._switchedFiles) { + if (this._astParseFailed && this._switchedFiles) { await rustContext.clearSceneAndBustCache( { settings: await jsAppSettings() }, codeManager.currentFilePath || undefined @@ -292,12 +292,12 @@ export class KclManager { async safeParse(code: string): Promise | null> { const result = parse(code) this.diagnostics = [] - this._hasErrors = false + this._astParseFailed = false if (err(result)) { const kclerror: KCLError = result as KCLError this.diagnostics = kclErrorsToDiagnostics([kclerror]) - this._hasErrors = true + this._astParseFailed = true await this.checkIfSwitchedFilesShouldClear() return null @@ -313,7 +313,7 @@ export class KclManager { this.addDiagnostics(complilationErrorsToDiagnostics(result.errors)) this.addDiagnostics(complilationErrorsToDiagnostics(result.warnings)) if (result.errors.length > 0) { - this._hasErrors = true + this._astParseFailed = true await this.checkIfSwitchedFilesShouldClear() return null diff --git a/src/machines/modelingMachine.ts b/src/machines/modelingMachine.ts index 6d2f1ec5756..044995a9d00 100644 --- a/src/machines/modelingMachine.ts +++ b/src/machines/modelingMachine.ts @@ -484,6 +484,9 @@ export const modelingMachine = setup({ 'Selection is on face': () => false, 'Has exportable geometry': () => false, 'has valid selection for deletion': () => false, + 'no kcl errors': () => { + return !kclManager.hasErrors() + }, 'is editing existing sketch': ({ context: { sketchDetails } }) => isEditingExistingSketch({ sketchDetails }), 'Can make selection horizontal': ({ context: { selectionRanges } }) => { @@ -2694,7 +2697,10 @@ export const modelingMachine = setup({ states: { hidePlanes: { on: { - 'Artifact graph populated': 'showPlanes', + 'Artifact graph populated': { + target: 'showPlanes', + guard: 'no kcl errors', + }, }, entry: 'hide default planes',