Enable/disable "start sketch", "edit sketch" and "extrude" appropriately (#1449)
* test that fails for when to enable extrude and sketch features * add fix to make test pass * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { ToolTip } from '../useStore'
|
||||
import { Selection } from 'lib/selections'
|
||||
import { Selection, Selections } from 'lib/selections'
|
||||
import {
|
||||
BinaryExpression,
|
||||
Program,
|
||||
@ -558,3 +558,24 @@ export function hasExtrudeSketchGroup({
|
||||
const varValue = programMemory?.root[varName]
|
||||
return varValue?.type === 'ExtrudeGroup' || varValue?.type === 'SketchGroup'
|
||||
}
|
||||
|
||||
export function isSingleCursorInPipe(
|
||||
selectionRanges: Selections,
|
||||
ast: Program
|
||||
) {
|
||||
if (selectionRanges.codeBasedSelections.length !== 1) return false
|
||||
if (
|
||||
doesPipeHaveCallExp({
|
||||
ast,
|
||||
selection: selectionRanges.codeBasedSelections[0],
|
||||
calleeName: 'extrude',
|
||||
})
|
||||
)
|
||||
return false
|
||||
const selection = selectionRanges.codeBasedSelections[0]
|
||||
const pathToNode = getNodePathFromSourceRange(ast, selection.range)
|
||||
const nodeTypes = pathToNode.map(([, type]) => type)
|
||||
if (nodeTypes.includes('FunctionExpression')) return false
|
||||
if (nodeTypes.includes('PipeExpression')) return true
|
||||
return false
|
||||
}
|
||||
|
Reference in New Issue
Block a user