diff --git a/src/Toolbar.tsx b/src/Toolbar.tsx index 540bc9647..82f3715ca 100644 --- a/src/Toolbar.tsx +++ b/src/Toolbar.tsx @@ -22,6 +22,7 @@ import { } from 'lib/toolbar' import { isDesktop } from 'lib/isDesktop' import { openExternalBrowserIfDesktop } from 'lib/openWindow' +import { convertSelectionsToOld } from 'lib/selections' export function Toolbar({ className = '', @@ -38,12 +39,17 @@ export function Toolbar({ '!border-transparent hover:!border-chalkboard-20 dark:enabled:hover:!border-primary pressed:!border-primary ui-open:!border-primary' const sketchPathId = useMemo(() => { - if (!isSingleCursorInPipe(context.selectionRanges, kclManager.ast)) { + if ( + !isSingleCursorInPipe( + convertSelectionsToOld(context.selectionRanges), + kclManager.ast + ) + ) { return false } return isCursorInSketchCommandRange( engineCommandManager.artifactGraph, - context.selectionRanges + convertSelectionsToOld(context.selectionRanges) ) }, [engineCommandManager.artifactGraph, context.selectionRanges]) diff --git a/src/clientSideScene/sceneEntities.ts b/src/clientSideScene/sceneEntities.ts index ea225309c..386c78752 100644 --- a/src/clientSideScene/sceneEntities.ts +++ b/src/clientSideScene/sceneEntities.ts @@ -1171,6 +1171,7 @@ export class SceneEntities { }, onMove: () => {}, onClick: (args) => { + console.log('onClick', args) if (args?.mouseEvent.which !== 1) return if (!args || !args.selected) { sceneInfra.modelingSend({ @@ -1183,6 +1184,7 @@ export class SceneEntities { } const { selected } = args const event = getEventForSegmentSelection(selected) + console.log('event', event) if (!event) return sceneInfra.modelingSend(event) }, diff --git a/src/components/AvailableVarsHelpers.tsx b/src/components/AvailableVarsHelpers.tsx index a3020544b..6083cd3b9 100644 --- a/src/components/AvailableVarsHelpers.tsx +++ b/src/components/AvailableVarsHelpers.tsx @@ -12,6 +12,7 @@ import { useKclContext } from 'lang/KclProvider' import { useModelingContext } from 'hooks/useModelingContext' import { executeAst } from 'lang/langHelpers' import { trap } from 'lib/trap' +import { convertSelectionsToOld } from 'lib/selections' export const AvailableVars = ({ onVarClick, @@ -96,7 +97,8 @@ export function useCalc({ } { const { programMemory } = useKclContext() const { context } = useModelingContext() - const selectionRange = context.selectionRanges.codeBasedSelections[0].range + const selectionRange = convertSelectionsToOld(context.selectionRanges) + .codeBasedSelections[0].range const inputRef = useRef(null) const [availableVarInfo, setAvailableVarInfo] = useState< ReturnType diff --git a/src/components/CommandBar/CommandBarSelectionInput.tsx b/src/components/CommandBar/CommandBarSelectionInput.tsx index 4bef30b82..c1a98ece8 100644 --- a/src/components/CommandBar/CommandBarSelectionInput.tsx +++ b/src/components/CommandBar/CommandBarSelectionInput.tsx @@ -5,6 +5,8 @@ import { CommandArgument } from 'lib/commandTypes' import { Selection__old, canSubmitSelectionArg, + convertSelectionToOld, + convertSelectionsToOld, getSelectionType, getSelectionTypeDisplayText, } from 'lib/selections' @@ -51,10 +53,14 @@ function CommandBarSelectionInput({ const [hasSubmitted, setHasSubmitted] = useState(false) const selection = useSelector(arg.machineActor, selectionSelector) const selectionsByType = useMemo(() => { - const selectionRangeEnd = selection?.codeBasedSelections[0]?.range[1] - return !selectionRangeEnd || selectionRangeEnd === code.length + const selectionRangeEnd = !selection + ? null + : convertSelectionsToOld(selection)?.codeBasedSelections[0]?.range[1] + return !selectionRangeEnd || selectionRangeEnd === code.length || !selection ? 'none' - : getSelectionType(selection) + : !selection + ? 'none' + : getSelectionType(convertSelectionsToOld(selection)) }, [selection, code]) const canSubmitSelection = useMemo( () => canSubmitSelectionArg(selectionsByType, arg), @@ -89,6 +95,8 @@ function CommandBarSelectionInput({ onSubmit(selection) } + const selectionOld = selection && convertSelectionsToOld(selection) + return (