Merge remote-tracking branch 'origin' into kurt-multi-profile-again

This commit is contained in:
Kurt Hutten Irev-Dev
2025-02-03 18:36:38 +11:00
847 changed files with 157001 additions and 72141 deletions

View File

@ -10,6 +10,7 @@ import {
SourceRange,
Expr,
defaultSourceRange,
topLevelRange,
} from 'lang/wasm'
import { ModelingMachineEvent } from 'machines/modelingMachine'
import { isNonNullable, uuidv4 } from 'lib/utils'
@ -17,11 +18,8 @@ import { EditorSelection, SelectionRange } from '@codemirror/state'
import { getNormalisedCoordinates, isOverlap } from 'lib/utils'
import { isCursorInSketchCommandRange } from 'lang/util'
import { Program } from 'lang/wasm'
import {
getNodeFromPath,
getNodePathFromSourceRange,
isSingleCursorInPipe,
} from 'lang/queryAst'
import { getNodeFromPath, isSingleCursorInPipe } from 'lang/queryAst'
import { getNodePathFromSourceRange } from 'lang/queryAstNodePathUtils'
import { CommandArgument } from './commandTypes'
import {
DefaultPlaneStr,
@ -63,7 +61,7 @@ type Selection__old =
| 'line-end'
| 'line-mid'
| 'extrude-wall'
| 'solid2D'
| 'solid2d'
| 'start-cap'
| 'end-cap'
| 'point'
@ -103,13 +101,13 @@ function convertSelectionToOld(selection: Selection): Selection__old | null {
// return {} as Selection__old
// TODO implementation
const _artifact = selection.artifact
if (_artifact?.type === 'solid2D') {
if (_artifact?.type === 'solid2d') {
const codeRef = getSolid2dCodeRef(
_artifact,
engineCommandManager.artifactGraph
)
if (err(codeRef)) return null
return { range: codeRef.range, type: 'solid2D' }
return { range: codeRef.range, type: 'solid2d' }
}
if (_artifact?.type === 'cap') {
const codeRef = getCapCodeRef(_artifact, engineCommandManager.artifactGraph)
@ -269,7 +267,7 @@ export function getEventForSegmentSelection(
selectionType: 'singleCodeCursor',
selection: {
codeRef: {
range: [node.node.start, node.node.end, true],
range: topLevelRange(node.node.start, node.node.end),
pathToNode: group.userData.pathToNode,
},
},
@ -382,10 +380,13 @@ export function processCodeMirrorRanges({
if (!isChange) return null
const codeBasedSelections: Selections['graphSelections'] =
codeMirrorRanges.map(({ from, to }) => {
const pathToNode = getNodePathFromSourceRange(ast, [from, to, true])
const pathToNode = getNodePathFromSourceRange(
ast,
topLevelRange(from, to)
)
return {
codeRef: {
range: [from, to, true],
range: topLevelRange(from, to),
pathToNode,
},
}
@ -448,7 +449,10 @@ function updateSceneObjectColors(codeBasedSelections: Selection[]) {
if (err(nodeMeta)) return
const node = nodeMeta.node
const groupHasCursor = codeBasedSelections.some((selection) => {
return isOverlap(selection?.codeRef?.range, [node.start, node.end, true])
return isOverlap(
selection?.codeRef?.range,
topLevelRange(node.start, node.end)
)
})
const color = groupHasCursor
@ -573,10 +577,9 @@ export function getSelectionTypeDisplayText(
.map(
// Hack for showing "face" instead of "extrude-wall" in command bar text
([type, count]) =>
`${count} ${type
.replace('wall', 'face')
.replace('solid2D', 'face')
.replace('segment', 'face')}${count > 1 ? 's' : ''}`
`${count} ${type.replace('wall', 'face').replace('solid2d', 'face')}${
count > 1 ? 's' : ''
}`
)
.join(', ')
}
@ -649,7 +652,7 @@ export function codeToIdSelections(
const artifact = engineCommandManager.artifactGraph.get(
entry.artifact.solid2dId || ''
)
if (artifact?.type !== 'solid2D') {
if (artifact?.type !== 'solid2d') {
bestCandidate = {
artifact: entry.artifact,
selection,
@ -871,7 +874,7 @@ export function updateSelections(
return {
artifact: artifact,
codeRef: {
range: [node.start, node.end, true],
range: topLevelRange(node.start, node.end),
pathToNode: pathToNode,
},
}
@ -885,7 +888,7 @@ export function updateSelections(
if (err(node)) return node
pathToNodeBasedSelections.push({
codeRef: {
range: [node.node.start, node.node.end, true],
range: topLevelRange(node.node.start, node.node.end),
pathToNode: pathToNode,
},
})