on master help sign in
Merge pull request #742 from michaelbjames/debugger

Update hotswap pause state location

commit9c54aeb5f3727cc0d196b7e625653aae9f754595 authorEvan Czaplicki <info@elm-lang.org> dateTue 12 Aug 2014, 17:20 (12 years ago) parent0d515f1f17000d
1 file changed+11−6
runtime/Debugger.js+11−6
runtime/Debugger.js+11−6
@@ -269,7 +269,11 @@ function debugModule(module, runtime) {
269269 };
270270}
271271
272−function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
272+// The debuggerHistory variable is passed in on hotswap. It represents
273+// the a state of the debugger for it to assume during init. It contains
274+// the paused state of the debugger, the recorded events, and the current
275+// event being processed.
276+function debuggerInit(debugModule, runtime, debuggerHistory /* =undefined */) {
273277 var currentEventIndex = 0;
274278
275279 function resetProgram(position) {
@@ -349,6 +353,7 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
349353 continueIndex = getMaxSteps();
350354 }
351355 return {
356+ paused: debugModule.getPaused(),
352357 recordedEvents: debugModule.copyRecordedEvents(),
353358 currentEventIndex: continueIndex
354359 };
@@ -360,15 +365,15 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
360365 parentNode.removeChild(runtime.node);
361366 }
362367
363− if (hotSwapState) {
368+ if (debuggerHistory) {
364369 // The problem is that we want to previous paused state. But
365370 // by the time JS reaches here, the old code has been swapped out
366371 // and the new modules are being generated. So we can ask the
367372 // debugging console what it thinks the pause state is and go
368373 // from there.
369− var paused = top.debug.paused;
374+ var paused = debuggerHistory.paused;
370375 debugModule.setPaused();
371− debugModule.loadRecordedEvents(hotSwapState.recordedEvents);
376+ debugModule.loadRecordedEvents(debuggerHistory.recordedEvents);
372377 var index = getMaxSteps();
373378 runtime.debuggerStatus.eventCounter = 0;
374379 debugModule.tracePath.clearTraces();
@@ -384,9 +389,9 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
384389 }
385390 debugModule.tracePath.stopRecording();
386391
387− stepTo(hotSwapState.currentEventIndex);
392+ stepTo(debuggerHistory.currentEventIndex);
388393 if (!paused) {
389− debugModule.setContinue(hotSwapState.currentEventIndex);
394+ debugModule.setContinue(debuggerHistory.currentEventIndex);
390395 }
391396 }
392397