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] &&