From 92b3f6192ddff152ca107abb323b1d25c080c0da Mon Sep 17 00:00:00 2001 From: Jonathan Tran Date: Thu, 1 Aug 2024 13:25:54 -0400 Subject: [PATCH] Fix executeAstMock to be more lenient --- src/lang/KclSingleton.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/lang/KclSingleton.ts b/src/lang/KclSingleton.ts index 07fcaff58..c2744103d 100644 --- a/src/lang/KclSingleton.ts +++ b/src/lang/KclSingleton.ts @@ -15,7 +15,11 @@ import { recast, SourceRange, } from 'lang/wasm' -import { expectNodeOnPath, getLastNodeFromPath } from './queryAst' +import { + expectNodeOnPath, + getLastNodeFromPath, + getNodeFromPath, +} from './queryAst' import { codeManager, editorManager, sceneInfra } from 'lib/singletons' import { Diagnostic } from '@codemirror/lint' @@ -315,12 +319,14 @@ export class KclManager { Object.entries(this.engineCommandManager.artifactMap).forEach( ([commandId, artifact]) => { if (!artifact.pathToNode) return - const node = expectNodeOnPath( + const _node = getNodeFromPath( this.ast, artifact.pathToNode, 'CallExpression' ) - if (err(node)) return + if (err(_node)) return + const { node } = _node + if (isArray(node) || node.type !== 'CallExpression') return const [oldStart, oldEnd] = artifact.range if (oldStart === 0 && oldEnd === 0) return if (oldStart === node.start && oldEnd === node.end) return