From 431de3d666bccf01c3a5383412575d87c99683ad Mon Sep 17 00:00:00 2001 From: Pierre Jacquier Date: Wed, 19 Mar 2025 13:32:41 -0400 Subject: [PATCH] Use updateModelingState in codemod --- src/machines/modelingMachine.ts | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/machines/modelingMachine.ts b/src/machines/modelingMachine.ts index 190223bc6..3f1421ee2 100644 --- a/src/machines/modelingMachine.ts +++ b/src/machines/modelingMachine.ts @@ -97,6 +97,7 @@ import { createProfileStartHandle } from 'clientSideScene/segments' import { DRAFT_POINT } from 'clientSideScene/sceneInfra' import { setAppearance } from 'lang/modifyAst/setAppearance' import { DRAFT_DASHED_LINE } from 'clientSideScene/sceneEntities' +import { updateModelingState } from 'lang/modelingWorkflows' export const MODELING_PERSIST_KEY = 'MODELING_PERSIST_KEY' @@ -2050,7 +2051,7 @@ export const modelingMachine = setup({ const trajectoryDeclarator = trajectoryNode.node.declaration // Perform the sweep - const addResult = addSweep({ + const { modifiedAst, pathToNode } = addSweep({ node: ast, targetDeclarator, trajectoryDeclarator, @@ -2058,20 +2059,17 @@ export const modelingMachine = setup({ variableName, insertIndex, }) - - const updatedAst = await kclManager.updateAst( - addResult.modifiedAst, - true, + await updateModelingState( + modifiedAst, { - focusPath: [addResult.pathToNode], + kclManager, + editorManager, + codeManager, + }, + { + focusPath: [pathToNode], } ) - - await codeManager.updateEditorWithAstAndWriteToFile(updatedAst.newAst) - - if (updatedAst?.selections) { - editorManager.selectRange(updatedAst?.selections) - } } ), loftAstMod: fromPromise(