M1.3 Wire smart insert into map click, preserve undo/redo #12
Labels
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
public/wanderer#12
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Replace append-on-click with the smart index from M1.2, reusing the existing splice/changeset/undo path. Start/finish clicks still extend ends. Manual + e2e verification.
Wiring plan (from the code read).
Map-click currently appends:
calculateRouteBetween(last, click) → insertIntoRoute(push). Change to computek = chooseInsertionIndex(anchors, click)(see #11), then:k === n→ append (unchanged)k === 0→ prepend: routeclick→anchors[0],insertIntoRoute(wp, 0). ⚠️insertIntoRoutehas anif(index)falsy-0 bug (valhalla_store.svelte.ts:116) — index 0 falls through topush; must fix/special-case.0 < k < n→ split the gap:editRoute(k-1, route(anchors[k-1]→click))+insertIntoRoute(route(click→anchors[k]), k)(mirrors the line-drag path) + insert the anchor marker at k.All paths already push changesets → undo/redo preserved. Also update the anchor-marker array + numbering.
✅ Done — commit
f0ea569eonfeat/smart-insertion.addAnchorSmart(lat, lon)in the route editor: computesk = chooseInsertionIndex(anchors, {lat,lon});k===Nkeeps the existing append path,0<k<Nsplits the segment betweenanchors[k-1]andanchors[k]and re-routes both halves (mirrorshandleSegmentDragEnd),k===0prepends a new start.addAnchorAndRecalculate→addAnchorSmart.insertIntoRouteindex-0 bug (valhalla_store.svelte.ts):if (index)→if (index !== undefined)(0 was falsy → appended). No existing caller passes 0; prepend relies on it.Verify:
svelte-checkclean (0 errors / 0 warnings, 2437 files);route_insertionunit tests 11/11 green. Browser/e2e validation pending a deploy (M0.2) or localnpm run dev.