@@ -175,22 +175,23 @@ function debugModule(module, runtime) {
175175 var pauseDelay = Date.now() - pauseTime;
176176 runtime.timer.addDelay(pauseDelay);
177177 programPaused = false;
178− if (position > 0) {
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.
181− var lastSnapshotPosition = Math.floor(position / EVENTS_PER_SAVE);
182− eventsUntilSnapshot = EVENTS_PER_SAVE - (position % EVENTS_PER_SAVE);
183− snapshots = snapshots.slice(0, lastSnapshotPosition + 1);
184−
185− var lastEventTime = recordedEvents[position-1].timestep;
178+
179+ // we need to dump the events that are ahead of where we're continuing.
180+ var lastSnapshotPosition = Math.floor(position / EVENTS_PER_SAVE);
181+ eventsUntilSnapshot = EVENTS_PER_SAVE - (position % EVENTS_PER_SAVE);
182+ snapshots = snapshots.slice(0, lastSnapshotPosition + 1);
183+
184+ if (position < getRecordedEventsLength()) {
185+ var lastEventTime = recordedEvents[position].timestep;
186186 var scrubTime = runtime.timer.now() - lastEventTime;
187187 runtime.timer.addDelay(scrubTime);
188−
189− recordedEvents = recordedEvents.slice(0, position);
190− tracePath.clearTracesAfter(position);
191− runtime.debuggerStatus.eventCounter = position;
192− executeCallbacks(asyncCallbacks, false);
193188 }
189+
190+ recordedEvents = recordedEvents.slice(0, position);
191+ tracePath.clearTracesAfter(position);
192+ runtime.debuggerStatus.eventCounter = position;
193+ executeCallbacks(asyncCallbacks, false);
194+
194195 tracePath.startRecording();
195196 }
196197
@@ -250,10 +251,6 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
250251 function continueProgram() {
251252 if (debugModule.getPaused())
252253 {
253− if (currentEventIndex === 0) {
254− restartProgram();
255− return;
256− }
257254 var closestSnapshotIndex =
258255 Math.floor(currentEventIndex / EVENTS_PER_SAVE) * EVENTS_PER_SAVE;
259256 resetProgram(currentEventIndex);