don't query program memory for add sketch line (#895)

* don't query program memory for add sketch line

* add issue TODO

* fmt

* fix test tsc
This commit is contained in:
Kurt Hutten
2023-10-18 07:30:03 +11:00
committed by GitHub
parent f1a14f1e3d
commit 93e806fc99
4 changed files with 29 additions and 23 deletions

View File

@ -193,9 +193,6 @@ export const line: SketchLineHelper = {
pathToNode,
'VariableDeclarator'
)
const variableName = varDec.id.name
const sketch = previousProgramMemory?.root?.[variableName]
if (sketch.type !== 'SketchGroup') throw new Error('not a SketchGroup')
const newXVal = createLiteral(roundOff(to[0] - from[0], 2))
const newYVal = createLiteral(roundOff(to[1] - from[1], 2))
@ -969,7 +966,8 @@ export function addNewSketchLn({
to,
fnName,
pathToNode,
}: Omit<CreateLineFnCallArgs, 'from'>): {
from,
}: CreateLineFnCallArgs): {
modifiedAst: Program
pathToNode: PathToNode
} {
@ -984,12 +982,6 @@ export function addNewSketchLn({
const { node: pipeExp, shallowPath: pipePath } = getNodeFromPath<
PipeExpression | CallExpression
>(node, pathToNode, 'PipeExpression')
const variableName = varDec.id.name
const sketch = previousProgramMemory?.root?.[variableName]
if (sketch.type !== 'SketchGroup') throw new Error('not a SketchGroup')
const last = sketch.value[sketch.value.length - 1] || sketch.start
const from = last.to
return add({
node,
previousProgramMemory,