@@ -108,22 +108,21 @@ function debugModule(module, runtime) {
108108 recordedEvents = events.slice();
109109 }
110110
111− function setPausedAt(v, position) {
112− programPaused = v;
113− if (programPaused) {
114− clearAsyncCallbacks();
115− tracePath.stopRecording();
116− }
117− else {
118− // executeCallbacks should only be called when continuing, not when restarting.
119− if(position > 0) {
120− // If we're unpausing not at the head, then we need to dump the
121− // events that are ahead of where we're continuing.
122− recordedEvents = recordedEvents.slice(0,position);
123− executeCallbacks(asyncCallbacks, false);
124− }
125− tracePath.startRecording();
111+ function setPaused() {
112+ programPaused = true;
113+ clearAsyncCallbacks();
114+ tracePath.stopRecording();
115+ }
116+
117+ function setContinue(position) {
118+ programPaused = false;
119+ if (position > 0) {
120+ // If we're not unpausing at the head, then we need to dump the
121+ // events that are ahead of where we're continuing.
122+ recordedEvents = recordedEvents.slice(0,position);
123+ executeCallbacks(asyncCallbacks, false);
126124 }
125+ tracePath.startRecording();
127126 }
128127
129128 function getPaused() {
@@ -167,7 +166,8 @@ function debugModule(module, runtime) {
167166 copyRecordedEvents: copyRecordedEvents,
168167 loadRecordedEvents: loadRecordedEvents,
169168 getPaused: getPaused,
170− setPausedAt: setPausedAt,
169+ setPaused: setPaused,
170+ setContinue: setContinue,
171171 tracePath: tracePath,
172172 watchTracker: watchTracker,
173173 };
@@ -187,12 +187,12 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
187187 debugModule.watchTracker.clear();
188188 debugModule.tracePath.clearTraces();
189189 debugModule.clearRecordedEvents();
190− debugModule.setPausedAt(false, 0);
190+ debugModule.setContinue(0);
191191 executeCallbacks(debugModule.initialAsyncCallbacks, true);
192192 }
193193
194194 function pauseProgram() {
195− debugModule.setPausedAt(true);
195+ debugModule.setPaused();
196196 eventCounter = debugModule.getRecordedEventsLength();
197197 }
198198
@@ -209,13 +209,13 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
209209 debugModule.tracePath.clearTraces();
210210 debugModule.tracePath.startRecording();
211211 stepTo(index);
212− debugModule.setPausedAt(false, eventCounter);
212+ debugModule.setContinue(eventCounter);
213213 }
214214 }
215215
216216 function stepTo(index) {
217217 if (!debugModule.getPaused()) {
218− debugModule.setPausedAt(true);
218+ debugModule.setPaused();
219219 resetProgram();
220220 }
221221
@@ -283,8 +283,8 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
283283 // and the new modules are being generated. So we can ask the
284284 // debugging console what it thinks the pause state is and go
285285 // from there.
286− var pauseState = top.debug.paused;
287− debugModule.setPausedAt(true);
286+ var paused = top.debug.paused;
287+ debugModule.setPaused();
288288 debugModule.loadRecordedEvents(hotSwapState.recordedEvents);
289289
290290 // draw new trace path
@@ -293,7 +293,11 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
293293 debugModule.tracePath.stopRecording();
294294
295295 stepTo(hotSwapState.eventCounter);
296− debugModule.setPausedAt(pauseState, hotSwapState.eventCounter);
296+ if (paused) {
297+ debugModule.setPaused();
298+ } else {
299+ debugModule.setContinue(hotSwapState.eventCounter);
300+ }
297301 }
298302
299303 runtime.node.parentNode.appendChild(debugModule.tracePath.canvas);