refactor code storage (#2144)

* refactor code storage

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* typo

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* for now dont do onupdate its lagging the editor

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* way smaller delay

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* turn abck on on update

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* dont be fancy

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix linter

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* empty

* empty

* good things

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* empty

* empty

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fixes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* make less flakey

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* go abck to errors for now

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2024-04-17 20:18:07 -07:00
committed by GitHub
parent 168fed038d
commit 3f8c4e7b5a
32 changed files with 314 additions and 370 deletions

View File

@ -52,7 +52,12 @@ import {
VariableDeclaration,
VariableDeclarator,
} from 'lang/wasm'
import { engineCommandManager, kclManager, sceneInfra } from 'lib/singletons'
import {
engineCommandManager,
kclManager,
sceneInfra,
codeManager,
} from 'lib/singletons'
import { getNodeFromPath, getNodePathFromSourceRange } from 'lang/queryAst'
import { executeAst, useStore } from 'useStore'
import {
@ -542,7 +547,7 @@ export class SceneEntities {
return
}
await kclManager.executeAstMock(modifiedAst, { updates: 'code' })
await kclManager.executeAstMock(modifiedAst)
this.setUpDraftSegment(
sketchPathToNode,
forward,
@ -637,9 +642,7 @@ export class SceneEntities {
spliceBetween: true,
})
addingNewSegmentStatus = 'pending'
await kclManager.executeAstMock(mod.modifiedAst, {
updates: 'code',
})
await kclManager.executeAstMock(mod.modifiedAst)
await this.tearDownSketch({ removeAxis: false })
this.setupSketch({
sketchPathToNode: pathToNode,
@ -784,9 +787,9 @@ export class SceneEntities {
;(async () => {
const code = recast(modifiedAst)
if (!draftInfo)
// don't want to mode the user's code yet as they have't committed to the change yet
// don't want to mod the user's code yet as they have't committed to the change yet
// plus this would be the truncated ast being recast, it would be wrong
kclManager.setCode(code, false)
codeManager.updateCodeStateEditor(code)
const { programMemory } = await executeAst({
ast: truncatedAst,
useFakeExecutor: true,