Repository navigation
fix(vscode): apply a routing change made during a drag when the drag settles - #1330
Conversation
…settles Co-Authored-By: jason.han <hanhuijun@gmail.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
…g-change-mid-drag Co-Authored-By: jason.han <hanhuijun@gmail.com>
…ttles The panel's tests now load its script into the markup the extension serves, shared through src/markup.ts, so the controls the script binds at load are the served ones and not a copy that drifts from them. Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
|
Native VS Code end-to-end comparison of this head (f26e199) against Gesture settlement: before and afterOn the branch, a node release without movement, Escape, a stationary empty-canvas release and a moved-pan release all switch from the stated diagonal with its one waypoint handle to the router's orthogonal route with none. The webview's event log confirms the routing message arrived while the pointer was held, with no render in between.
Pan preservation and controls
|
…where it left the canvas Co-Authored-By: jason.han <hanhuijun@gmail.com>
… keeps its viewport Co-Authored-By: jason.han <hanhuijun@gmail.com>
… the scroll is not clamped Co-Authored-By: jason.han <hanhuijun@gmail.com>
|
Native VS Code run of dd25007 (VSIX rebuilt and installed; pointer really held; routing changed through the setting; no render between pointerdown and the routing message in any measured gesture). Node drag whose preview draws a smaller canvas, cancelled with Escape — 195% zoom, the Target node dragged left from Same drag released — preview and offsets unchanged through pointerup; the saved edit moved Target to (229, 200) and left the Link's stated waypoint (250, 150) alone; the render of the saved edit then drew the smaller canvas (viewBox Held preview keeps its routing — model-start drag, model → router while held, second move: the stated diagonal and its waypoint handle stayed; Escape applied router routing and cancelled the edit. Moved pan + Escape at 381%: rerouted with both offsets kept at (983.3333129882812, 297.5), also once settled. |
What and why
Changing
opensysml.diagram.routingwhile a drag is in progress left the old routes on screen after the drag ended. Theroutingmessage handler ineditors/vscode/src/webview/diagram.tsrightly declines to redraw under a held pointer, butsettle()re-lays the drawing out only whenunroutedis set, and only the router's own late load set it. So a routing change during a gesture was recorded (applyRoutingupdatedrouting) and then forgotten: a release-as-click or an Escape cancel put the pre-change layout back, and the drawing stayed stale until some later render. The pan gesture (a press on empty canvas) ends beforesettle()is reached at all, so the same held there.Reproduction on
develop(the sequence the new tests drive):renderwithrouting: "model"on a connection with a statedDiagramLayout::Route— the diagonal is drawn verbatim with its waypoint handle.pointerdownon a node (a gesture begins; nothing has moved).routing: "router"arrives — the handler seesgestureand does not redraw (correct),routingis nowrouter.pointerupwithout movement →endGesture→unroutedis false →settle()is skipped → the model-routed drawing with its waypoint handle is still on screen. Same with Escape instead of release (cancelGesture→settle()only whenmoved || unrouted), and with the press on empty canvas instead of a node (the pan branch ofendGesturereturns beforesettle()).Fix:
applyRoutingnow marks the layout on screen as predating the routing change (unrouted = true) when a gesture holds the screen, so the gesture's end re-lays out through the existingsettle()path; the pan branch ofendGesturesettles anunroutedlayout like the other gestures do. Every gesture records the routing it began under, andpanelOverrides()reads that while a gesture is in progress, so a drag's preview stays on the layout the drag started from rather than switching modes under the held node.panTorecords the viewport as it scrolls the container (the scroll listener hears of it a task later than the pan's end might redraw), so a redraw at a pan's end, released or cancelled, puts the pan's offsets back; a drag's preview is laid out on the canvas the drag began on (layoutCanvaswithheldcovers the held layout's canvas), so a preview that draws less no longer shrinks the scrollable canvas and clamps the offsets under the pointer, and a cancelled drag comes back where it was.unrouted's comment now says "the router loaded or the routing changed mid-gesture". No behaviour changes when the routing message carries the routing already in force (applyRoutingreturns before touching anything, as before) or when no gesture is in progress (the handler redraws at once, as before).The panel's markup (the controls and regions its script binds by id) moves from the
htmltemplate ineditors/vscode/src/diagram.tstoeditors/vscode/src/markup.ts, which the template and the new test both read, so the test loads the script into the markup the extension serves rather than a copy of it.In-flight overlap
Open PRs touching
editors/vscode/src/webview: #1320 (related elements), #1328 (api-json bridge; its webview delta is develop's own code from a stale base). Neither touchesapplyRouting,settle,unroutedor theroutingmessage handler. #1318 (diagram navigation) merged intodevelopwhile this PR was open and is merged in here; its pan gesture is covered by the fix. PR-less remote branches touching the webview:fix/webview-collapsed-ports(layout/canvas/autolayout, no change todiagram.ts) anddocs/landing-runtime-environment-label(layout.test.tsonly). No overlap with this change.How it was verified
New
editors/vscode/src/webview/diagram.test.tsloads the panel script into the markup the extension serves it in (jsdom, fakedacquireVsCodeApi, libavoid loaded fromnode_modules) and drives it through themessageand pointer events: a routing change during a drag is applied on release, on Escape, and at the end of a pan; a drag's preview keeps the routing it began under until the drag ends; a pan cancelled after a routing change is redrawn where it left the canvas; a drag's preview and the layout put back after Escape keep the canvas the drag began on (and alayoutCanvascase:heldcovers the held canvas, and still grows beyond it); and a routing message that leaves the routing as it is redraws nothing. The six regression tests fail without the fix (stale waypoint handles after the gesture, the preview switching modes mid-drag,scrollLeftback at 0, a preview canvas smaller than the held one) and pass with it.jsdom.d.tsgains theurlandpretendToBeVisualconstructor options: the panel's message handler accepts only its own origin, and its viewport work is scheduled in animation frames.Extension gate (
editors/vscode, as the VS Code extension CI job runs it), on the head merged with currentdevelop:No Go code is touched.
Checklist
make testandmake lintpass locally — not applicable: no Go code touched; the extension's own gate (build, typecheck, test) passeschanges/unreleased/diagram-routing-change-mid-drag.fixed.md, not as an edit toCHANGELOG.mdmake docs-countsrun if a gate count moved — no gate count movedF4,K5) in the body, docs, or changelogLink to Devin session: https://nasa-jpl-demo.devinenterprise.com/sessions/a63fa6cf47fa4ce29879754d525288bd
Open in Devin Desktop: https://nasa-jpl-demo.devinenterprise.com/desktop/session/a63fa6cf47fa4ce29879754d525288bd?variant=devin
Requested by: @HuiJun