Add selection guard and clean up

This commit is contained in:
Pierre Jacquier
2024-12-05 14:06:09 -05:00
parent 12859598a3
commit e4b0de0ead
6 changed files with 45 additions and 16 deletions

View File

@ -70,6 +70,7 @@ import {
} from 'lang/modifyAst'
import { Program, parse, recast } from 'lang/wasm'
import {
doesSceneHaveExtrudedSketch,
doesSceneHaveSweepableSketch,
getNodePathFromSourceRange,
isSingleCursorInPipe,
@ -586,18 +587,21 @@ export const ModelingMachineProvider = ({
if (err(canLoft)) return false
return canLoft
},
'has valid shell selection': ({ context: { selectionRanges } }) => {
'has valid shell selection': ({
context: { selectionRanges },
event,
}) => {
const hasNoSelection =
selectionRanges.graphSelections.length === 0 ||
isRangeBetweenCharacters(selectionRanges) ||
isSelectionLastLine(selectionRanges, codeManager.code)
if (hasNoSelection) {
// TODO: find extrude in ast
// return doesSceneHaveSweepableSketch(kclManager.ast, count)
return doesSceneHaveExtrudedSketch(kclManager.ast)
}
const canShell = canShellSelection(selectionRanges)
console.log('canShellSelection', canShellSelection(selectionRanges))
if (err(canShell)) return false
return canShell
},