Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Make all stepping sagas stop when trace finished
Browse files Browse the repository at this point in the history
  • Loading branch information
haltman-at committed Jun 11, 2019
1 parent 1a88bf9 commit 16368b9
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions packages/truffle-debugger/lib/controller/sagas/index.js
Expand Up @@ -124,16 +124,20 @@ function* stepInto() {
const startingRange = yield select(controller.current.location.sourceRange);
var currentDepth;
var currentRange;
var finished;

do {
yield* stepNext();

currentDepth = yield select(controller.current.functionDepth);
currentRange = yield select(controller.current.location.sourceRange);
finished = yield select(controller.current.trace.finished);
} while (
//we aren't finished,
!finished &&
// the function stack has not increased,
currentDepth <= startingDepth &&
// the current source range begins on or after the starting range
// the current source range begins on or after the starting range,
currentRange.start >= startingRange.start &&
// and the current range ends on or before the starting range ends
currentRange.start + currentRange.length <=
Expand All @@ -144,7 +148,8 @@ function* stepInto() {
/**
* Step out of the current function
*
* This will run until the debugger encounters a decrease in function depth.
* This will run until the debugger encounters a decrease in function depth
* (or finishes)
*/
function* stepOut() {
if (yield select(controller.current.location.isMultiline)) {
Expand All @@ -154,12 +159,14 @@ function* stepOut() {

const startingDepth = yield select(controller.current.functionDepth);
var currentDepth;
var finished;

do {
yield* stepNext();

currentDepth = yield select(controller.current.functionDepth);
} while (currentDepth >= startingDepth);
finished = yield select(controller.current.trace.finished);
} while (!finished && currentDepth >= startingDepth);
}

/**
Expand All @@ -173,15 +180,19 @@ function* stepOver() {
const startingRange = yield select(controller.current.location.sourceRange);
var currentDepth;
var currentRange;
var finished;

do {
yield* stepNext();

currentDepth = yield select(controller.current.functionDepth);
currentRange = yield select(controller.current.location.sourceRange);
finished = yield select(controller.current.trace.finished);
} while (
// keep stepping provided:
//
// we haven't finished
!finished &&
// we haven't jumped out
!(currentDepth < startingDepth) &&
// either: function depth is greater than starting (ignore function calls)
Expand Down

0 comments on commit 16368b9

Please sign in to comment.