@@ -21,6 +21,7 @@ Elm.debuggerAttach = function(module, hotSwapState /* =undefined */) {
23var EVENTS_PER_SAVE = 100;
23var EVENTS_PER_SAVE = 100;
25function dispatchElmDebuggerInit() {
26function dispatchElmDebuggerInit() {
26 if (parent.window) {
27 if (parent.window) {
@@ -81,8 +82,8 @@ function debugModule(module, runtime) {
81 return false;
82 return false;
84− var changed = runtime.notify(id, v, timestep);
85 recordEvent(id, v, timestep);
85 recordEvent(id, v, timestep);
86+ var changed = runtime.notify(id, v, timestep);
86 if (eventsUntilSnapshot === 1) {
87 if (eventsUntilSnapshot === 1) {
87 saveSnapshot();
88 saveSnapshot();
88 eventsUntilSnapshot = EVENTS_PER_SAVE;
89 eventsUntilSnapshot = EVENTS_PER_SAVE;
@@ -115,6 +116,7 @@ function debugModule(module, runtime) {
115 function recordEvent(id, v, timestep) {
116 function recordEvent(id, v, timestep) {
116 watchTracker.pushFrame();
117 watchTracker.pushFrame();
117 recordedEvents.push({ id:id, value:v, timestep:timestep });
118 recordedEvents.push({ id:id, value:v, timestep:timestep });
120 function clearAsyncCallbacks() {
122 function clearAsyncCallbacks() {
@@ -127,6 +129,7 @@ function debugModule(module, runtime) {
128 function clearRecordedEvents() {
130 function clearRecordedEvents() {
129 recordedEvents = [];
131 recordedEvents = [];
132 function getRecordedEventsLength() {
135 function getRecordedEventsLength() {
@@ -177,6 +180,8 @@ function debugModule(module, runtime) {
177 eventsUntilSnapshot = EVENTS_PER_SAVE - (position % EVENTS_PER_SAVE);
180 eventsUntilSnapshot = EVENTS_PER_SAVE - (position % EVENTS_PER_SAVE);
178 snapshots = snapshots.slice(0, lastSnapshotPosition);
181 snapshots = snapshots.slice(0, lastSnapshotPosition);
179 recordedEvents = recordedEvents.slice(0, position);
182 recordedEvents = recordedEvents.slice(0, position);
183+ tracePath.clearTracesAfter(position);
184+ eventCounter = position;
180 executeCallbacks(asyncCallbacks, false);
185 executeCallbacks(asyncCallbacks, false);
182 tracePath.startRecording();
187 tracePath.startRecording();
@@ -216,7 +221,6 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
216 var closestSnapshot = debugModule.getSnapshotAt(position);
221 var closestSnapshot = debugModule.getSnapshotAt(position);
217 debugModule.clearAsyncCallbacks();
222 debugModule.clearAsyncCallbacks();
218 restoreSnapshot(debugModule.signalGraphNodes, closestSnapshot);
223 restoreSnapshot(debugModule.signalGraphNodes, closestSnapshot);
219− // clear traces here.
220 redrawGraphics();
224 redrawGraphics();
@@ -314,11 +318,14 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
314 debugModule.loadRecordedEvents(hotSwapState.recordedEvents);
318 debugModule.loadRecordedEvents(hotSwapState.recordedEvents);
315 var index = getMaxSteps();
319 var index = getMaxSteps();
316 var eventsUntilSnapshot = EVENTS_PER_SAVE;
320 var eventsUntilSnapshot = EVENTS_PER_SAVE;
322+ debugModule.tracePath.clearTraces();
318 // draw new trace path
324 // draw new trace path
319 debugModule.tracePath.startRecording();
325 debugModule.tracePath.startRecording();
320 while(currentEventIndex < index) {
326 while(currentEventIndex < index) {
321 var nextEvent = debugModule.getRecordedEventAt(currentEventIndex);
327 var nextEvent = debugModule.getRecordedEventAt(currentEventIndex);
322 runtime.notify(nextEvent.id, nextEvent.value, nextEvent.timestep);
329 runtime.notify(nextEvent.id, nextEvent.value, nextEvent.timestep);
323 if (eventsUntilSnapshot === 1) {
330 if (eventsUntilSnapshot === 1) {
324 debugModule.saveSnapshot();
331 debugModule.saveSnapshot();
@@ -403,14 +410,19 @@ function tracePathInit(runtime, signalGraphMain) {
403 for (var id in positions) {
410 for (var id in positions) {
404 var pos = positions[id];
411 var pos = positions[id];
405 if (tracePositions.hasOwnProperty(id)) {
412 if (tracePositions.hasOwnProperty(id)) {
406− var points = tracePositions[id];
413+ tracePositions[id].push(pos);
407− if (!pos.equals(points[points.length-1])) {
412 tracePositions[id] = [pos];
416 tracePositions[id] = [pos];
418+ if (tracePositions[id].length < eventCounter) {
419+ var padCount = eventCounter - tracePositions[id].length;
420+ var lastTracePosition = tracePositions[id][tracePositions[id].length - 1];
421+ for (var i = padCount; i--;) {
422+ tracePositions[id].push(lastTracePosition)
425+ assert(tracePositions[id].length === eventCounter, "We don't have a 1-1 mapping of trace positions to events")
@@ -468,10 +480,19 @@ function tracePathInit(runtime, signalGraphMain) {
468 recordingTraces = true;
480 recordingTraces = true;
483+ function clearTracesAfter(position) {
485+ for (var id in tracePositions) {
486+ newTraces[id] = tracePositions[id].slice(0,position);
488+ tracePositions = newTraces;
472 graphicsUpdate: graphicsUpdate,
492 graphicsUpdate: graphicsUpdate,
473 canvas: tracePathCanvas,
493 canvas: tracePathCanvas,
474 clearTraces: clearTraces,
494 clearTraces: clearTraces,
495+ clearTracesAfter: clearTracesAfter,
475 stopRecording: stopRecording,
496 stopRecording: stopRecording,
476 startRecording: startRecording
497 startRecording: startRecording