From 5a8882dfcb663d22e48970043eefe799a9a0e5cb Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Wed, 13 May 2026 05:07:34 +0200 Subject: [PATCH] Implement logic to determine path point insertion anchor ID --- src/app/App.tsx | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/app/App.tsx b/src/app/App.tsx index 1f15bfd8..e6ec16ef 100644 --- a/src/app/App.tsx +++ b/src/app/App.tsx @@ -1399,6 +1399,45 @@ function getSelectedPathPointState( }; } +function getPathPointInsertionAnchorId( + selection: EditorSelection, + path: ScenePath | null, + activeSelectionId: string | null +): string | null { + if (path === null) { + return null; + } + + if (selection.kind === "pathPoint" && selection.pathId === path.id) { + return selection.pointId; + } + + if (selection.kind !== "pathPoints" || selection.pathId !== path.id) { + return null; + } + + if ( + activeSelectionId !== null && + selection.pointIds.includes(activeSelectionId) + ) { + return activeSelectionId; + } + + let anchorId: string | null = null; + let anchorIndex = -1; + + for (const pointId of selection.pointIds) { + const pointIndex = getScenePathPointIndex(path, pointId); + + if (pointIndex > anchorIndex) { + anchorIndex = pointIndex; + anchorId = pointId; + } + } + + return anchorId; +} + function isModelAsset(asset: ProjectAssetRecord): asset is ModelAssetRecord { return asset.kind === "model"; }