#5783 Only show axis planes when there are no errors (#5799)

* Only show axis planes when there are no errors

* run prettier

* A snapshot a day keeps the bugs away! 📷🐛

* KclSingleton hasErrors refactor

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Andrew Varga
2025-03-21 11:44:44 +01:00
committed by GitHub
parent e8feb0309b
commit 869126e436
4 changed files with 13 additions and 7 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 72 KiB

View File

@ -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<Node<Program> | 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

View File

@ -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',