Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selections Refactor #4381

Merged
merged 75 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
a961f6c
selection stuff
Irev-Dev Nov 4, 2024
34f9132
A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest)
github-actions[bot] Nov 4, 2024
f8420f8
trigger CI
Irev-Dev Nov 4, 2024
50df35e
Merge remote-tracking branch 'origin' into kurt-selctions-stuff
Irev-Dev Nov 5, 2024
312e8fd
fix bugs
Irev-Dev Nov 7, 2024
821c8d8
Merge remote-tracking branch 'origin' into kurt-selctions-stuff
Irev-Dev Nov 7, 2024
0668598
Merge remote-tracking branch 'origin' into kurt-selctions-stuff
Irev-Dev Nov 8, 2024
ff2feec
some edge cut stuff
Irev-Dev Nov 10, 2024
88aca15
Merge remote-tracking branch 'origin' into kurt-selctions-stuff
Irev-Dev Nov 10, 2024
802bd52
A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
github-actions[bot] Nov 10, 2024
2437247
trigger CI
Irev-Dev Nov 10, 2024
a8d1d1f
A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores)
github-actions[bot] Nov 10, 2024
3bcacc4
fix sketch mode issues
Irev-Dev Nov 12, 2024
dc70cf7
Merge remote-tracking branch 'origin' into kurt-selctions-stuff
Irev-Dev Nov 12, 2024
6337468
fix more tests, selection in sketch related
Irev-Dev Nov 12, 2024
6d5dfe9
more test fixing
Irev-Dev Nov 12, 2024
9d8a280
A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores)
github-actions[bot] Nov 12, 2024
af66a97
Trigger ci
Irev-Dev Nov 12, 2024
f3cdd66
A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores)
github-actions[bot] Nov 12, 2024
0823afa
Trigger ci
Irev-Dev Nov 12, 2024
0fcabcd
more sketch mode selection fixes
Irev-Dev Nov 13, 2024
8e97776
Merge remote-tracking branch 'origin' into kurt-selctions-stuff
Irev-Dev Nov 13, 2024
baca781
fix unit tests
Irev-Dev Nov 13, 2024
a1c1345
rename function
Irev-Dev Nov 13, 2024
562d928
remove .only
Irev-Dev Nov 13, 2024
46b770a
migrate a more selections types
Irev-Dev Nov 13, 2024
31aee1a
migrate a more selections types
Irev-Dev Nov 13, 2024
8aab2d3
migrate a more selections types
Irev-Dev Nov 13, 2024
144a683
lint
Irev-Dev Nov 13, 2024
e0113e6
migrate a more selections types
Irev-Dev Nov 13, 2024
4000cac
Merge remote-tracking branch 'origin' into kurt-selctions-stuff
Irev-Dev Nov 13, 2024
ff8eaf1
migrate a more selections types
Irev-Dev Nov 13, 2024
029d8e5
migrate a more selections types
Irev-Dev Nov 13, 2024
9780dae
migrate a more selections types
Irev-Dev Nov 13, 2024
8e718b8
migrate a more selections types
Irev-Dev Nov 13, 2024
257e1ba
migrate a more selections types
Irev-Dev Nov 13, 2024
60af4f5
migrate a more selections types
Irev-Dev Nov 13, 2024
4fac8be
migrate a more selections types
Irev-Dev Nov 13, 2024
66c0c65
migrate a more selections types
Irev-Dev Nov 13, 2024
519c69f
migrate a more selections types
Irev-Dev Nov 13, 2024
0ce93cf
fix bad pathToNode issue
Irev-Dev Nov 13, 2024
65acf1c
A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores)
github-actions[bot] Nov 13, 2024
69d1089
fix sketch on face
Irev-Dev Nov 14, 2024
ff67bcd
migrate a more selections types
Irev-Dev Nov 14, 2024
9117bbf
migrate a more selections types
Irev-Dev Nov 14, 2024
d2bccae
fix code selection of fillets
Irev-Dev Nov 14, 2024
7ede833
migrate a more selections types
Irev-Dev Nov 15, 2024
4ed3882
Merge remote-tracking branch 'origin' into kurt-selctions-stuff
Irev-Dev Nov 15, 2024
57fd35c
migrate a more selections types
Irev-Dev Nov 15, 2024
d8edbda
migrate a more selections types
Irev-Dev Nov 15, 2024
35721a5
migrate a more selections types
Irev-Dev Nov 15, 2024
30e1d72
migrate a more selections types
Irev-Dev Nov 18, 2024
14ac96d
Merge remote-tracking branch 'origin' into kurt-selctions-stuff
Irev-Dev Nov 18, 2024
2493dce
fix bad path to node, looks like a race
Irev-Dev Nov 18, 2024
0db7e5d
migrate a more selections types
Irev-Dev Nov 18, 2024
126b865
migrate a more selections types
Irev-Dev Nov 18, 2024
989742c
fix cmd bar selections
Irev-Dev Nov 18, 2024
b313981
fix cmd bar selections
Irev-Dev Nov 18, 2024
47259c0
fix display issues
Irev-Dev Nov 18, 2024
0d0e453
migrate a more selections types
Irev-Dev Nov 18, 2024
9ebd383
Merge remote-tracking branch 'origin' into kurt-selctions-stuff
Irev-Dev Nov 18, 2024
13413e1
Revert "migrate a more selections types"
Irev-Dev Nov 18, 2024
801f33e
migrate a more selections types
Irev-Dev Nov 18, 2024
ddcaa61
clean up1
Irev-Dev Nov 18, 2024
a481d9b
clean up 2
Irev-Dev Nov 18, 2024
670a399
Merge remote-tracking branch 'origin' into kurt-selctions-stuff
Irev-Dev Nov 18, 2024
8348906
Merge remote-tracking branch 'origin' into kurt-selctions-stuff
Irev-Dev Nov 19, 2024
efe8a3b
fix types after main merge
Irev-Dev Nov 19, 2024
bee49de
review tweaks
Irev-Dev Nov 19, 2024
1d43b41
fix wall selection bug
Irev-Dev Nov 20, 2024
a65213d
Merge remote-tracking branch 'origin' into kurt-selctions-stuff
Irev-Dev Nov 20, 2024
705abf4
Update src/lang/std/engineConnection.ts
Irev-Dev Nov 20, 2024
7939ad6
add franks TODO comment
Irev-Dev Nov 20, 2024
be20ba9
fix type after main merge, plus a touch of clean up
Irev-Dev Nov 20, 2024
c2418e0
Merge branch 'main' into kurt-selctions-stuff
Irev-Dev Nov 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions src/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ 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(context.selectionRanges, kclManager.ast))
return false
}
return isCursorInSketchCommandRange(
engineCommandManager.artifactGraph,
context.selectionRanges
Expand Down
6 changes: 2 additions & 4 deletions src/clientSideScene/sceneEntities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,10 +578,8 @@ export class SceneEntities {
draftExpressionsIndices &&
index <= draftExpressionsIndices.end &&
index >= draftExpressionsIndices.start
const isSelected = selectionRanges?.codeBasedSelections.some(
(selection) => {
return isOverlap(selection.range, segment.__geoMeta.sourceRange)
}
const isSelected = selectionRanges?.graphSelections.some((selection) =>
isOverlap(selection?.codeRef?.range, segment.__geoMeta.sourceRange)
)

let seg: Group
Expand Down
18 changes: 14 additions & 4 deletions src/components/AstExplorer.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { useModelingContext } from 'hooks/useModelingContext'
import { editorManager, kclManager } from 'lib/singletons'
import { editorManager, engineCommandManager, kclManager } from 'lib/singletons'
import { getNodeFromPath, getNodePathFromSourceRange } from 'lang/queryAst'
import { useEffect, useRef, useState } from 'react'
import { trap } from 'lib/trap'
import { codeToIdSelections } from 'lib/selections'
import { codeRefFromRange } from 'lang/std/artifactGraph'

export function AstExplorer() {
const { context } = useModelingContext()
const pathToNode = getNodePathFromSourceRange(
// TODO maybe need to have callback to make sure it stays in sync
kclManager.ast,
context.selectionRanges.codeBasedSelections?.[0]?.range
context.selectionRanges.graphSelections?.[0]?.codeRef?.range
)
const [filterKeys, setFilterKeys] = useState<string[]>(['start', 'end'])

Expand Down Expand Up @@ -121,13 +123,21 @@ function DisplayObj({
editorManager.setHighlightRange([[obj?.start || 0, obj.end]])
}}
onClick={(e) => {
const range: [number, number] = [obj?.start || 0, obj.end || 0]
const idInfo = codeToIdSelections([
{ codeRef: codeRefFromRange(range, kclManager.ast) },
])[0]
const artifact = engineCommandManager.artifactGraph.get(
idInfo?.id || ''
)
if (!artifact) return
send({
type: 'Set selection',
data: {
selectionType: 'singleCodeCursor',
selection: {
type: 'default',
range: [obj?.start || 0, obj.end || 0],
artifact: artifact,
codeRef: codeRefFromRange(range, kclManager.ast),
},
},
})
Expand Down
4 changes: 3 additions & 1 deletion src/components/AvailableVarsHelpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ export function useCalc({
} {
const { programMemory } = useKclContext()
const { context } = useModelingContext()
const selectionRange = context.selectionRanges.codeBasedSelections[0].range
const selectionRange =
context.selectionRanges?.graphSelections[0]?.codeRef?.range
const inputRef = useRef<HTMLInputElement>(null)
const [availableVarInfo, setAvailableVarInfo] = useState<
ReturnType<typeof findAllPreviousVariables>
Expand Down Expand Up @@ -157,6 +158,7 @@ export function useCalc({
engineCommandManager,
useFakeExecutor: true,
programMemoryOverride: kclManager.programMemory.clone(),
idGenerator: kclManager.execState.idGenerator,
}).then(({ execState }) => {
const resultDeclaration = ast.body.find(
(a) =>
Expand Down
20 changes: 12 additions & 8 deletions src/components/CommandBar/CommandBarSelectionInput.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useSelector } from '@xstate/react'
import { useCommandsContext } from 'hooks/useCommandsContext'
import { useKclContext } from 'lang/KclProvider'
import { Artifact } from 'lang/std/artifactGraph'
import { CommandArgument } from 'lib/commandTypes'
import {
Selection,
canSubmitSelectionArg,
getSelectionType,
getSelectionTypeDisplayText,
Expand All @@ -12,13 +12,13 @@ import { modelingMachine } from 'machines/modelingMachine'
import { useEffect, useMemo, useRef, useState } from 'react'
import { StateFrom } from 'xstate'

const semanticEntityNames: { [key: string]: Array<Selection['type']> } = {
face: ['extrude-wall', 'start-cap', 'end-cap'],
edge: ['edge', 'line', 'arc'],
point: ['point', 'line-end', 'line-mid'],
const semanticEntityNames: { [key: string]: Array<Artifact['type']> } = {
face: ['wall', 'cap', 'solid2D'],
edge: ['segment', 'sweepEdge', 'edgeCutEdge'],
point: [],
Comment on lines +15 to +18
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be cool to have a diagram that showed what operation generated what semantic entities.
I know we have the visualized artifact graph but some short hand like

extrude -> wall, cap, ... so you know the list of possible values.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if the feature tree will end up being the best visualisation for this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I guess it won't have our internal names, it will just be face :/ defeating the purpose.

}

function getSemanticSelectionType(selectionType: Array<Selection['type']>) {
function getSemanticSelectionType(selectionType: Array<Artifact['type']>) {
const semanticSelectionType = new Set()
selectionType.forEach((type) => {
Object.entries(semanticEntityNames).forEach(([entity, entityTypes]) => {
Expand Down Expand Up @@ -49,8 +49,12 @@ 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
: selection?.graphSelections[0]?.codeRef?.range[1]
return !selectionRangeEnd || selectionRangeEnd === code.length || !selection
? 'none'
: !selection
? 'none'
: getSelectionType(selection)
}, [selection, code])
Expand Down
8 changes: 4 additions & 4 deletions src/components/CustomIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1170,15 +1170,15 @@ const CustomIconMap = {
xmlns="http://www.w3.org/2000/svg"
>
<path
fill-rule="evenodd"
clip-rule="evenodd"
fillRule="evenodd"
clipRule="evenodd"
d="M7.95705 5.99046C7.05643 6.44935 6.33654 7.19809 5.91336 8.11602C5.49019 9.03396 5.38838 10.0676 5.62434 11.0505C5.8603 12.0334 6.42029 12.9081 7.21408 13.5339C8.00787 14.1597 8.98922 14.5 10 14.5C11.0108 14.5 11.9921 14.1597 12.7859 13.5339C13.5797 12.9082 14.1397 12.0334 14.3757 11.0505C14.6116 10.0676 14.5098 9.03396 14.0866 8.11603C13.6635 7.19809 12.9436 6.44935 12.043 5.99046L12.497 5.09946C13.5977 5.66032 14.4776 6.57544 14.9948 7.69737C15.512 8.81929 15.6364 10.0827 15.348 11.2839C15.0596 12.4852 14.3752 13.5544 13.405 14.3192C12.4348 15.0841 11.2354 15.5 10 15.5C8.7646 15.5 7.56517 15.0841 6.59499 14.3192C5.6248 13.5544 4.94037 12.4852 4.65197 11.2839C4.36357 10.0827 4.488 8.81929 5.00522 7.69736C5.52243 6.57544 6.40231 5.66032 7.50306 5.09946L7.95705 5.99046Z"
fill="currentColor"
/>
<path d="M10 5.5V4M10 4H8M10 4H12" stroke="currentColor" />
<path
fill-rule="evenodd"
clip-rule="evenodd"
fillRule="evenodd"
clipRule="evenodd"
d="M12.8536 7.85356L10.3536 10.3536C10.1583 10.5488 9.84171 10.5488 9.64645 10.3536C9.45118 10.1583 9.45118 9.84172 9.64645 9.64645L12.1464 7.14645L12.8536 7.85356Z"
fill="currentColor"
/>
Expand Down
5 changes: 4 additions & 1 deletion src/components/EngineCommands.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ export const EngineCommands = () => {
)
})}
</div>
<button data-testid="clear-commands" onClick={clearEngineCommands}>
<button
data-testid="clear-commands"
onClick={() => clearEngineCommands()}
>
Clear
</button>
<br />
Expand Down
41 changes: 24 additions & 17 deletions src/components/ModelingMachineProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ import {
} from './Toolbar/SetAngleBetween'
import { applyConstraintAngleLength } from './Toolbar/setAngleLength'
import {
Selections,
canSweepSelection,
handleSelectionBatch,
isSelectionLastLine,
isRangeBetweenCharacters,
isSketchPipe,
Selections,
updateSelections,
} from 'lib/selections'
import { applyConstraintIntersect } from './Toolbar/Intersect'
Expand Down Expand Up @@ -318,7 +318,7 @@ export const ModelingMachineProvider = ({
})
}
let selections: Selections = {
codeBasedSelections: [],
graphSelections: [],
otherSelections: [],
}
if (setSelections.selectionType === 'singleCodeCursor') {
Expand All @@ -328,21 +328,21 @@ export const ModelingMachineProvider = ({
!editorManager.isShiftDown
) {
selections = {
codeBasedSelections: [],
graphSelections: [],
otherSelections: [],
}
} else if (
setSelections.selection &&
!editorManager.isShiftDown
) {
selections = {
codeBasedSelections: [setSelections.selection],
graphSelections: [setSelections.selection],
otherSelections: [],
}
} else if (setSelections.selection && editorManager.isShiftDown) {
selections = {
codeBasedSelections: [
...selectionRanges.codeBasedSelections,
graphSelections: [
...selectionRanges.graphSelections,
setSelections.selection,
],
otherSelections: selectionRanges.otherSelections,
Expand Down Expand Up @@ -378,18 +378,18 @@ export const ModelingMachineProvider = ({
if (setSelections.selectionType === 'otherSelection') {
if (editorManager.isShiftDown) {
selections = {
codeBasedSelections: selectionRanges.codeBasedSelections,
graphSelections: selectionRanges.graphSelections,
otherSelections: [setSelections.selection],
}
} else {
selections = {
codeBasedSelections: [],
graphSelections: [],
otherSelections: [setSelections.selection],
}
}
const { engineEvents, updateSceneObjectColors } =
handleSelectionBatch({
selections,
selections: selections,
})
engineEvents &&
engineEvents.forEach((event) => {
Expand Down Expand Up @@ -558,7 +558,7 @@ export const ModelingMachineProvider = ({
// A user can begin extruding if they either have 1+ faces selected or nothing selected
// TODO: I believe this guard only allows for extruding a single face at a time
const hasNoSelection =
selectionRanges.codeBasedSelections.length === 0 ||
selectionRanges.graphSelections.length === 0 ||
isRangeBetweenCharacters(selectionRanges) ||
isSelectionLastLine(selectionRanges, codeManager.code)

Expand All @@ -570,21 +570,24 @@ export const ModelingMachineProvider = ({
}
if (!isSketchPipe(selectionRanges)) return false

return canSweepSelection(selectionRanges)
const canSweep = canSweepSelection(selectionRanges)
if (err(canSweep)) return false
return canSweep
},
'has valid selection for deletion': ({
context: { selectionRanges },
}) => {
if (!commandBarState.matches('Closed')) return false
if (selectionRanges.codeBasedSelections.length <= 0) return false
if (selectionRanges.graphSelections.length <= 0) return false
return true
},
'has valid fillet selection': ({ context: { selectionRanges } }) =>
hasValidFilletSelection({
'has valid fillet selection': ({ context: { selectionRanges } }) => {
return hasValidFilletSelection({
selectionRanges,
ast: kclManager.ast,
code: codeManager.code,
}),
})
},
'Selection is on face': ({ context: { selectionRanges }, event }) => {
if (event.type !== 'Enter sketch') return false
if (event.data?.forceNewSketch) return false
Expand Down Expand Up @@ -691,7 +694,8 @@ export const ModelingMachineProvider = ({
}),
'animate-to-sketch': fromPromise(
async ({ input: { selectionRanges } }) => {
const sourceRange = selectionRanges.codeBasedSelections[0].range
const sourceRange =
selectionRanges.graphSelections[0]?.codeRef?.range
const sketchPathToNode = getNodePathFromSourceRange(
kclManager.ast,
sourceRange
Expand All @@ -713,6 +717,7 @@ export const ModelingMachineProvider = ({
}
}
),

'Get horizontal info': fromPromise(
async ({ input: { selectionRanges, sketchDetails } }) => {
const { modifiedAst, pathToNodeMap } =
Expand Down Expand Up @@ -848,7 +853,9 @@ export const ModelingMachineProvider = ({
'Get length info': fromPromise(
async ({ input: { selectionRanges, sketchDetails } }) => {
const { modifiedAst, pathToNodeMap } =
await applyConstraintAngleLength({ selectionRanges })
await applyConstraintAngleLength({
selectionRanges,
})
const _modifiedAst = parse(recast(modifiedAst))
if (!sketchDetails)
return Promise.reject(new Error('No sketch details'))
Expand Down
6 changes: 3 additions & 3 deletions src/components/Toolbar/EqualAngle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export function equalAngleInfo({
enabled: boolean
}
| Error {
const paths = selectionRanges.codeBasedSelections.map(({ range }) =>
getNodePathFromSourceRange(kclManager.ast, range)
const paths = selectionRanges.graphSelections.map(({ codeRef }) =>
getNodePathFromSourceRange(kclManager.ast, codeRef.range)
)
const _nodes = paths.map((pathToNode) => {
const tmp = getNodeFromPath<Expr>(kclManager.ast, pathToNode)
Expand Down Expand Up @@ -64,7 +64,7 @@ export function equalAngleInfo({
const transforms = getTransformInfos(
{
...selectionRanges,
codeBasedSelections: selectionRanges.codeBasedSelections.slice(1),
graphSelections: selectionRanges.graphSelections.slice(1),
},
kclManager.ast,
'equalAngle'
Expand Down
18 changes: 6 additions & 12 deletions src/components/Toolbar/EqualLength.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { toolTips } from 'lang/langHelpers'
import { Selections } from 'lib/selections'
import { Program, Expr, VariableDeclarator } from '../../lang/wasm'
import {
getNodePathFromSourceRange,
getNodeFromPath,
} from '../../lang/queryAst'
import { getNodeFromPath } from '../../lang/queryAst'
import { isSketchVariablesLinked } from '../../lang/std/sketchConstraints'
import {
transformSecondarySketchLinesTagFirst,
Expand All @@ -26,22 +23,19 @@ export function setEqualLengthInfo({
enabled: boolean
}
| Error {
const paths = selectionRanges.codeBasedSelections.map(({ range }) =>
getNodePathFromSourceRange(kclManager.ast, range)
)
const _nodes = paths.map((pathToNode) => {
const tmp = getNodeFromPath<Expr>(kclManager.ast, pathToNode)
const _nodes = selectionRanges.graphSelections.map(({ codeRef }) => {
const tmp = getNodeFromPath<Expr>(kclManager.ast, codeRef.pathToNode)
if (err(tmp)) return tmp
return tmp.node
})
const _err1 = _nodes.find(err)
if (err(_err1)) return _err1
const nodes = _nodes as Expr[]

const _varDecs = paths.map((pathToNode) => {
const _varDecs = selectionRanges.graphSelections.map(({ codeRef }) => {
const tmp = getNodeFromPath<VariableDeclarator>(
kclManager.ast,
pathToNode,
codeRef.pathToNode,
'VariableDeclarator'
)
if (err(tmp)) return tmp
Expand All @@ -65,7 +59,7 @@ export function setEqualLengthInfo({
const transforms = getTransformInfos(
{
...selectionRanges,
codeBasedSelections: selectionRanges.codeBasedSelections.slice(1),
graphSelections: selectionRanges.graphSelections.slice(1),
},
kclManager.ast,
'equalLength'
Expand Down
12 changes: 3 additions & 9 deletions src/components/Toolbar/HorzVert.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { toolTips } from 'lang/langHelpers'
import { Selections } from 'lib/selections'
import { Program, ProgramMemory, Expr } from '../../lang/wasm'
import {
getNodePathFromSourceRange,
getNodeFromPath,
} from '../../lang/queryAst'
import { getNodeFromPath } from '../../lang/queryAst'
import {
PathToNodeMap,
getTransformInfos,
Expand All @@ -24,11 +21,8 @@ export function horzVertInfo(
enabled: boolean
}
| Error {
const paths = selectionRanges.codeBasedSelections.map(({ range }) =>
getNodePathFromSourceRange(kclManager.ast, range)
)
const _nodes = paths.map((pathToNode) => {
const tmp = getNodeFromPath<Expr>(kclManager.ast, pathToNode)
const _nodes = selectionRanges.graphSelections.map(({ codeRef }) => {
const tmp = getNodeFromPath<Expr>(kclManager.ast, codeRef.pathToNode)
if (err(tmp)) return tmp
return tmp.node
})
Expand Down
Loading
Loading