Fix to update the code in the editor before executing (#5976)

* Fix spelling

* Fix to update the code in the editor before executing
This commit is contained in:
Jonathan Tran
2025-03-25 05:06:27 -04:00
committed by GitHub
parent f7f7d9fa2c
commit 58dc3382eb
11 changed files with 192 additions and 134 deletions

View File

@ -123,6 +123,8 @@ import { Node } from '@rust/kcl-lib/bindings/Node'
import { radToDeg } from 'three/src/math/MathUtils'
import toast from 'react-hot-toast'
import { getArtifactFromRange, codeRefFromRange } from 'lang/std/artifactGraph'
import { updateModelingState } from 'lang/modelingWorkflows'
import { EXECUTION_TYPE_MOCK } from 'lib/constants'
type DraftSegment = 'line' | 'tangentialArcTo'
@ -1075,7 +1077,11 @@ export class SceneEntities {
return
}
await kclManager.executeAstMock(modifiedAst)
await updateModelingState(modifiedAst, EXECUTION_TYPE_MOCK, {
kclManager,
editorManager,
codeManager,
})
if (intersectsProfileStart) {
sceneInfra.modelingSend({ type: 'Close sketch' })
@ -1090,8 +1096,6 @@ export class SceneEntities {
segmentName
)
}
await codeManager.updateEditorWithAstAndWriteToFile(modifiedAst)
},
onMove: (args) => {
const expressionIndex = Number(sketchEntryNodePath[1][0])
@ -1303,13 +1307,16 @@ export class SceneEntities {
_ast = pResult.program
// Update the primary AST and unequip the rectangle tool
await kclManager.executeAstMock(_ast)
sceneInfra.modelingSend({ type: 'Finish rectangle' })
//
// lee: I had this at the bottom of the function, but it's
// possible sketchFromKclValue "fails" when sketching on a face,
// and this couldn't wouldn't run.
await codeManager.updateEditorWithAstAndWriteToFile(_ast)
await updateModelingState(_ast, EXECUTION_TYPE_MOCK, {
kclManager,
editorManager,
codeManager,
})
sceneInfra.modelingSend({ type: 'Finish rectangle' })
},
})
return {
@ -1493,13 +1500,16 @@ export class SceneEntities {
_ast = pResult.program
// Update the primary AST and unequip the rectangle tool
await kclManager.executeAstMock(_ast)
sceneInfra.modelingSend({ type: 'Finish center rectangle' })
//
// lee: I had this at the bottom of the function, but it's
// possible sketchFromKclValue "fails" when sketching on a face,
// and this couldn't wouldn't run.
await codeManager.updateEditorWithAstAndWriteToFile(_ast)
await updateModelingState(_ast, EXECUTION_TYPE_MOCK, {
kclManager,
editorManager,
codeManager,
})
sceneInfra.modelingSend({ type: 'Finish center rectangle' })
}
},
})
@ -1678,9 +1688,12 @@ export class SceneEntities {
_ast = pResult.program
// Update the primary AST and unequip the rectangle tool
await kclManager.executeAstMock(_ast)
await updateModelingState(_ast, EXECUTION_TYPE_MOCK, {
kclManager,
editorManager,
codeManager,
})
sceneInfra.modelingSend({ type: 'Finish circle three point' })
await codeManager.updateEditorWithAstAndWriteToFile(_ast)
}
},
})
@ -1912,9 +1925,12 @@ export class SceneEntities {
_ast = pResult.program
// Update the primary AST and unequip the arc tool
await kclManager.executeAstMock(_ast)
await updateModelingState(_ast, EXECUTION_TYPE_MOCK, {
kclManager,
editorManager,
codeManager,
})
sceneInfra.modelingSend({ type: 'Finish arc' })
await codeManager.updateEditorWithAstAndWriteToFile(_ast)
}
},
})
@ -2166,13 +2182,16 @@ export class SceneEntities {
_ast = pResult.program
// Update the primary AST and unequip the arc tool
await kclManager.executeAstMock(_ast)
await updateModelingState(_ast, EXECUTION_TYPE_MOCK, {
kclManager,
editorManager,
codeManager,
})
if (intersectsProfileStart) {
sceneInfra.modelingSend({ type: 'Close sketch' })
} else {
sceneInfra.modelingSend({ type: 'Finish arc' })
}
await codeManager.updateEditorWithAstAndWriteToFile(_ast)
}
},
})
@ -2364,9 +2383,12 @@ export class SceneEntities {
_ast = pResult.program
// Update the primary AST and unequip the rectangle tool
await kclManager.executeAstMock(_ast)
await updateModelingState(_ast, EXECUTION_TYPE_MOCK, {
kclManager,
editorManager,
codeManager,
})
sceneInfra.modelingSend({ type: 'Finish circle' })
await codeManager.updateEditorWithAstAndWriteToFile(_ast)
}
},
})