quick bugfix (#78)
This commit is contained in:
@ -347,6 +347,11 @@ export function splitPathAtLastIndex(pathToNode: PathToNode): {
|
||||
path: pathToNode.slice(0, -1),
|
||||
index: last,
|
||||
}
|
||||
} else if (pathToNode.length === 0) {
|
||||
return {
|
||||
path: [],
|
||||
index: -1,
|
||||
}
|
||||
}
|
||||
return splitPathAtLastIndex(pathToNode.slice(0, -1))
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ export function findAllPreviousVariables(
|
||||
const { node: bodyItems } = getNodeFromPath<Program['body']>(ast, bodyPath)
|
||||
|
||||
const variables: PrevVariable<any>[] = []
|
||||
bodyItems.forEach((item) => {
|
||||
bodyItems?.forEach?.((item) => {
|
||||
if (item.type !== 'VariableDeclaration' || item.end > sourceRange[0]) return
|
||||
const varName = item.declarations[0].id.name
|
||||
const varValue = programMemory?.root[varName]
|
||||
|
@ -1272,7 +1272,8 @@ export function addNewSketchLn({
|
||||
pathToNode,
|
||||
}: Omit<CreateLineFnCallArgs, 'from'>): { modifiedAst: Program } {
|
||||
const node = JSON.parse(JSON.stringify(_node))
|
||||
const { add, updateArgs } = sketchLineHelperMap[fnName]
|
||||
const { add, updateArgs } = sketchLineHelperMap?.[fnName] || {}
|
||||
if (!add || !updateArgs) throw new Error('not a sketch line helper')
|
||||
const { node: varDec } = getNodeFromPath<VariableDeclarator>(
|
||||
node,
|
||||
pathToNode,
|
||||
|
Reference in New Issue
Block a user