Fix move only working first time (#850)
* nuke fixIdMappings * update readme * remove sourceRangeMap as it was redundant repeated state already covered by the artifactMap * bug fix, name conflict * bug fix * update artifact map when sketch is first created * update artifact map for line generation too * fmt * update move state to allow selections * allow for selection of vertices some what hacky, but better than nothing * unnecessary react hook dependency * generic react linting * move working for non-execute case * block partial contrained things too for now
This commit is contained in:
@ -209,7 +209,11 @@ export const line: SketchLineHelper = {
|
||||
pipe.body[callIndex] = callExp
|
||||
return {
|
||||
modifiedAst: _node,
|
||||
pathToNode,
|
||||
pathToNode: [
|
||||
...pathToNode,
|
||||
['body', 'PipeExpression'],
|
||||
[callIndex, 'CallExpression'],
|
||||
],
|
||||
valueUsedInTransform,
|
||||
}
|
||||
}
|
||||
@ -220,6 +224,14 @@ export const line: SketchLineHelper = {
|
||||
])
|
||||
if (pipe.type === 'PipeExpression') {
|
||||
pipe.body = [...pipe.body, callExp]
|
||||
return {
|
||||
modifiedAst: _node,
|
||||
pathToNode: [
|
||||
...pathToNode,
|
||||
['body', 'PipeExpression'],
|
||||
[pipe.body.length - 1, 'CallExpression'],
|
||||
],
|
||||
}
|
||||
} else {
|
||||
varDec.init = createPipeExpression([varDec.init, callExp])
|
||||
}
|
||||
@ -909,7 +921,7 @@ export function changeSketchArguments(
|
||||
sourceRange: SourceRange,
|
||||
args: [number, number],
|
||||
from: [number, number]
|
||||
): { modifiedAst: Program } {
|
||||
): { modifiedAst: Program; pathToNode: PathToNode } {
|
||||
const _node = { ...node }
|
||||
const thePath = getNodePathFromSourceRange(_node, sourceRange)
|
||||
const { node: callExpression, shallowPath } = getNodeFromPath<CallExpression>(
|
||||
@ -929,7 +941,7 @@ export function changeSketchArguments(
|
||||
})
|
||||
}
|
||||
|
||||
throw new Error('not a sketch line helper')
|
||||
throw new Error(`not a sketch line helper: ${callExpression?.callee?.name}`)
|
||||
}
|
||||
|
||||
interface CreateLineFnCallArgs {
|
||||
@ -959,6 +971,7 @@ export function addNewSketchLn({
|
||||
pathToNode,
|
||||
}: Omit<CreateLineFnCallArgs, 'from'>): {
|
||||
modifiedAst: Program
|
||||
pathToNode: PathToNode
|
||||
} {
|
||||
const node = JSON.parse(JSON.stringify(_node))
|
||||
const { add, updateArgs } = sketchLineHelperMap?.[fnName] || {}
|
||||
|
Reference in New Issue
Block a user