Skip to content

Instantly share code, notes, and snippets.

@jimblandy
Forked from jasonLaster/foo.diff
Last active November 1, 2017 20:48
Show Gist options
  • Save jimblandy/f69102697848805d4140173172fba50d to your computer and use it in GitHub Desktop.
Save jimblandy/f69102697848805d4140173172fba50d to your computer and use it in GitHub Desktop.
modified src/utils/scopes.js
@@ -70,13 +70,14 @@ function getSourceBindingVariables(
return bound.concat(unused);
}
-export function getSpecialVariables(pauseInfo: Pause, path: string) {
- const thrown = get(pauseInfo, "why.frameFinished.throw", undefined);
-
- const returned = get(pauseInfo, "why.frameFinished.return", undefined);
+export function getFramePopVariables(pauseInfo: Pause, path: string) {
+ if (!pauseInfo.why || !pauseInfo.why.frameFinished) {
+ return;
+ }
const vars = [];
+ const thrown = pauseInfo.why.frameFinished.throw;
if (thrown !== undefined) {
vars.push({
name: "<exception>",
@@ -85,6 +86,7 @@ export function getSpecialVariables(pauseInfo: Pause, path: string) {
});
}
+ const returned = pauseInfo.why.frameFinished.return;
if (returned !== undefined) {
// Do not display a return value of "undefined",
if (!returned || !returned.type || returned.type !== "undefined") {
@@ -133,7 +135,6 @@ export function getScopes(
const scopes = [];
let scope = selectedScope;
- const pausedScopeActor = get(pauseInfo, "frame.scope.actor");
let scopeIndex = 1;
do {
@@ -155,9 +156,12 @@ export function getScopes(
? getSourceBindingVariables(bindings, sourceBindings, key)
: getBindingVariables(bindings, key);
- // show exception, return, and this variables in innermost scope
- if (scope.actor === pausedScopeActor) {
- vars = vars.concat(getSpecialVariables(pauseInfo, key));
+ // On the innermost scope of a frame that is just about to be popped, show
+ // the return value or the exception being thrown as special variables.
+ if (scope.actor === selectedScope.actor &&
+ selectedFrame.id == pauseInfo.frame.id)
+ {
+ vars = vars.concat(getFramePopVariables(pauseInfo, key));
}
if (scope.actor === selectedScope.actor) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment