Horz/Vert distance constraint with modal workflow (#43)

* button style tweak

* Remove duplication constraint ast transforms

* giveSketchFnCallTag to return if line already had a tag

* remove duplication

* update tag name to referenceSegName

* Update transform shape to return key details about the transform

* add modal to hor vert distance workflow

* fix browser env stuff from breaking tests

* fmt
This commit is contained in:
Kurt Hutten
2023-03-07 15:45:59 +11:00
committed by GitHub
parent a0518c556f
commit 2ac24bcd95
16 changed files with 376 additions and 203 deletions

View File

@ -481,15 +481,17 @@ export function createBinaryExpression([left, operator, right]: [
export function giveSketchFnCallTag(
ast: Program,
range: Range
): { modifiedAst: Program; tag: string } {
range: Range,
tag?: string
): { modifiedAst: Program; tag: string; isTagExisting: boolean } {
const { node: primaryCallExp } = getNodeFromPath<CallExpression>(
ast,
getNodePathFromSourceRange(ast, range)
)
const firstArg = getFirstArg(primaryCallExp)
const isTagExisting = !!firstArg.tag
const tagValue = (firstArg.tag ||
createLiteral(findUniqueName(ast, 'seg', 2))) as Literal
createLiteral(tag || findUniqueName(ast, 'seg', 2))) as Literal
const tagStr = String(tagValue.value)
const newFirstArg = createFirstArg(
primaryCallExp.callee.name as TooTip,
@ -500,5 +502,6 @@ export function giveSketchFnCallTag(
return {
modifiedAst: ast,
tag: tagStr,
isTagExisting,
}
}