@@ -175,22 +175,23 @@ function debugModule(module, runtime) {
175 var pauseDelay = Date.now() - pauseTime;
175 var pauseDelay = Date.now() - pauseTime;
176 runtime.timer.addDelay(pauseDelay);
176 runtime.timer.addDelay(pauseDelay);
177 programPaused = false;
177 programPaused = false;
178− if (position > 0) {
178+
179− // If we're not unpausing at the head, then we need to dump the
180− // events that are ahead of where we're continuing.
179+ // we need to dump the events that are ahead of where we're continuing.
181− var lastSnapshotPosition = Math.floor(position / EVENTS_PER_SAVE);
180+ var lastSnapshotPosition = Math.floor(position / EVENTS_PER_SAVE);
182− eventsUntilSnapshot = EVENTS_PER_SAVE - (position % EVENTS_PER_SAVE);
181+ eventsUntilSnapshot = EVENTS_PER_SAVE - (position % EVENTS_PER_SAVE);
183− snapshots = snapshots.slice(0, lastSnapshotPosition + 1);
182+ snapshots = snapshots.slice(0, lastSnapshotPosition + 1);
184+ if (position < getRecordedEventsLength()) {
185− var lastEventTime = recordedEvents[position-1].timestep;
185+ var lastEventTime = recordedEvents[position].timestep;
186 var scrubTime = runtime.timer.now() - lastEventTime;
186 var scrubTime = runtime.timer.now() - lastEventTime;
187 runtime.timer.addDelay(scrubTime);
187 runtime.timer.addDelay(scrubTime);
189− recordedEvents = recordedEvents.slice(0, position);
190− tracePath.clearTracesAfter(position);
191− runtime.debuggerStatus.eventCounter = position;
192− executeCallbacks(asyncCallbacks, false);
190+ recordedEvents = recordedEvents.slice(0, position);
191+ tracePath.clearTracesAfter(position);
192+ runtime.debuggerStatus.eventCounter = position;
193+ executeCallbacks(asyncCallbacks, false);
194 tracePath.startRecording();
195 tracePath.startRecording();
@@ -250,10 +251,6 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
250 function continueProgram() {
251 function continueProgram() {
251 if (debugModule.getPaused())
252 if (debugModule.getPaused())
253− if (currentEventIndex === 0) {
257 var closestSnapshotIndex =
254 var closestSnapshotIndex =
258 Math.floor(currentEventIndex / EVENTS_PER_SAVE) * EVENTS_PER_SAVE;
255 Math.floor(currentEventIndex / EVENTS_PER_SAVE) * EVENTS_PER_SAVE;
259 resetProgram(currentEventIndex);
256 resetProgram(currentEventIndex);