Update selections after constraint is applied [equal length, parallel, snap to x or y] (#2543)

* migrate one constraint

* typo

* update snap to y, snap to x, horz align, vert align, equal length

* add some e2e tests

* add e2e test for snap to axis contsraits

* remove works for now
This commit is contained in:
Kurt Hutten
2024-05-30 13:28:29 +10:00
committed by GitHub
parent e6641e68f3
commit 4b676d47da
6 changed files with 407 additions and 112 deletions

View File

@ -34,6 +34,7 @@ import {
handleSelectionBatch,
isSelectionLastLine,
isSketchPipe,
updateSelections,
} from 'lib/selections'
import { applyConstraintIntersect } from './Toolbar/Intersect'
import { applyConstraintAbsDistance } from './Toolbar/SetAbsDistance'
@ -53,6 +54,7 @@ import {
} from 'lang/modifyAst'
import {
Program,
Value,
VariableDeclaration,
coreDump,
parse,
@ -73,10 +75,7 @@ import { useSearchParams } from 'react-router-dom'
import { letEngineAnimateAndSyncCamAfter } from 'clientSideScene/CameraControls'
import { getVarNameModal } from 'hooks/useToolbarGuards'
import useHotkeyWrapper from 'lib/hotkeyWrapper'
import {
EngineConnectionState,
EngineConnectionStateType,
} from 'lang/std/engineConnection'
import { applyConstraintEqualAngle } from './Toolbar/EqualAngle'
type MachineContext<T extends AnyStateMachine> = {
state: StateFrom<T>
@ -223,8 +222,7 @@ export const ModelingMachineProvider = ({
: {}
),
'Set selection': assign(({ selectionRanges }, event) => {
if (event.type !== 'Set selection') return {} // this was needed for ts after adding 'Set selection' action to on done modal events
const setSelections = event.data
const setSelections = event.data as SetSelections // this was needed for ts after adding 'Set selection' action to on done modal events
if (!editorManager.editorView) return {}
const dispatchSelection = (selection?: EditorSelection) => {
if (!selection) return // TODO less of hack for the below please
@ -311,6 +309,12 @@ export const ModelingMachineProvider = ({
selectionRanges: selections,
}
}
if (setSelections.selectionType === 'completeSelection') {
editorManager.selectRange(setSelections.selection)
return {
selectionRanges: setSelections.selection,
}
}
return {}
}),