Fix: Opposite adjacent edge selection (#3896)

* fix opposite adjacent edge selection

* make test more robust
This commit is contained in:
Kurt Hutten
2024-09-17 05:38:58 +10:00
committed by GitHub
parent 0ff820d4da
commit 8d48c17395
3 changed files with 214 additions and 19 deletions

View File

@ -52,6 +52,7 @@ export type Selection = {
| 'end-cap'
| 'point'
| 'edge'
| 'adjacent-edge'
| 'line'
| 'arc'
| 'all'
@ -146,6 +147,15 @@ export async function getEventForSelectWithPoint({
engineCommandManager.artifactGraph
)
if (err(codeRef)) return null
if (_artifact?.subType === 'adjacent') {
return {
type: 'Set selection',
data: {
selectionType: 'singleCodeCursor',
selection: { range: codeRef.range, type: 'adjacent-edge' },
},
}
}
return {
type: 'Set selection',
data: {
@ -557,6 +567,37 @@ function codeToIdSelections(
}
return
}
if (type === 'edge' && entry.artifact.type === 'segment') {
const edges = getArtifactsOfTypes(
{ keys: entry.artifact.edgeIds, types: ['extrudeEdge'] },
engineCommandManager.artifactGraph
)
const edge = [...edges].find(
([_, edge]) => edge.type === 'extrudeEdge'
)
if (!edge) return
bestCandidate = {
artifact: edge[1],
selection: { type, range, ...rest },
id: edge[0],
}
}
if (type === 'adjacent-edge' && entry.artifact.type === 'segment') {
const edges = getArtifactsOfTypes(
{ keys: entry.artifact.edgeIds, types: ['extrudeEdge'] },
engineCommandManager.artifactGraph
)
const edge = [...edges].find(
([_, edge]) =>
edge.type === 'extrudeEdge' && edge.subType === 'adjacent'
)
if (!edge) return
bestCandidate = {
artifact: edge[1],
selection: { type, range, ...rest },
id: edge[0],
}
}
if (
(type === 'end-cap' || type === 'start-cap') &&
entry.artifact.type === 'path'