From 7150c01aa7bf55322a332683cdcd52f3f89976c2 Mon Sep 17 00:00:00 2001 From: "nori-sessions[bot]" <264258699+nori-sessions[bot]@users.noreply.github.com> Date: Mon, 2 Nov 2026 11:11:34 +0000 Subject: [PATCH] Previous piece selects the last piece built on a closed circuit too Co-authored-by: Nori --- e2e/track-edit-selection.spec.ts | 5 +++++ src/ui/coaster-panel.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/e2e/track-edit-selection.spec.ts b/e2e/track-edit-selection.spec.ts index c5b1a0dd..d00d0a8e 100644 --- a/e2e/track-edit-selection.spec.ts +++ b/e2e/track-edit-selection.spec.ts @@ -217,6 +217,11 @@ async function editClosedCircuit(page: Page, mobile: boolean, testInfo: TestInfo await expect(rideInfo(page)).toContainText('Circuit complete'); await expect(selectionLine(page)).toContainText('Building from the end of the track'); await shot(page, testInfo, 'circuit-rebuilt', point); + // With nothing selected, Previous picks the last piece built: here the one that closed the gap. + await page.getByRole('button', { name: 'Previous piece' }).click(); + await expect(selectionLine(page)).toContainText('Selected piece 7 of 14'); + await page.getByRole('button', { name: 'Track end' }).click(); + await expect(selectionLine(page)).toContainText('Building from the end of the track'); await toolbarAction(page, 'Resume'); await fastForward(page); diff --git a/src/ui/coaster-panel.ts b/src/ui/coaster-panel.ts index b83fe9b0..05685b87 100644 --- a/src/ui/coaster-panel.ts +++ b/src/ui/coaster-panel.ts @@ -462,7 +462,7 @@ export class CoasterPanel { if (!snapshot || !decodeCursor(info[RideInfo.Cursor]).hasTrack) return -1; for (let row = 0; row < snapshot.tracks.count; row++) { const piece = snapshotPiece(snapshot, snapshot.trackLinks[row * TRACK_LINK_STRIDE]); - if (!piece || piece.rideId !== ride.id || piece.next >= 0) continue; + if (!piece || piece.rideId !== ride.id) continue; const exit = pieceExit(piece.pieceType, piece.x, piece.y, piece.z, piece.dir); if ( exit.x === info[RideInfo.CursorX] &&