fix vertex selection (#869)

This commit is contained in:
Kurt Hutten
2023-10-16 15:29:02 +11:00
committed by GitHub
parent b257b202c3
commit 8fad9ef3c2
5 changed files with 38 additions and 14 deletions

View File

@ -160,15 +160,24 @@ export const TextEditor = ({
)
const idBasedSelections = codeBasedSelections
.map(({ type, range }) => {
const hasOverlap = Object.entries(
// TODO #868: loops over all artifacts will become inefficient at a large scale
const entriesWithOverlap = Object.entries(
engineCommandManager.artifactMap || {}
).filter(([_, { range: artifactRange }]) => {
return artifactRange && isOverlap(artifactRange, range)
).filter(([_, artifact]) => {
return artifact.range && isOverlap(artifact.range, range)
? artifact
: false
})
if (hasOverlap.length) {
if (entriesWithOverlap.length) {
const [id, artifact] = entriesWithOverlap?.[0]
return {
type,
id: hasOverlap?.[0]?.[0],
id:
type === 'line-end' &&
artifact.type === 'result' &&
artifact.headVertexId
? artifact.headVertexId
: id,
}
}
return null