Skip to content

Commit

Permalink
fix: call frame names appearing duplicated, this not appearing (#158)
Browse files Browse the repository at this point in the history
* fix: call frame names appearing duplicated, `this` not appearing

Fixes #150

 - We always used the scope name as the reported name to VS Code,
   but there might be multiple scope names of different types.
 - Also in the issue, I noticed that `this` wasn't present. In the old
   adapters, we always add `this` to the top call scope. In PWA that
   was only happening if the top scope was `local` (and we never tried
   to add it anywhere if that wasn't the case). The most technically
   correct thing to do would be to show it at the nearest `local` scope,
   but I think showing it at the top is more useful and is what
   people are used to.

* fixup! update unit tests
  • Loading branch information
connor4312 authored Dec 5, 2019
1 parent 89d0519 commit 0a41897
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/adapter/stackTrace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export class StackFrame {
if (scope.name && scope.type === 'closure') {
name = localize('scope.closureNamed', 'Closure ({0})', scope.name);
} else if (scope.name) {
name = scope.name;
name = `${name}: ${scope.name}`;
}

const variable = await this._scopeVariable(scopeNumber);
Expand Down Expand Up @@ -289,7 +289,7 @@ export class StackFrame {
if (!scope.variables[scopeNumber]) {
const scopeRef: ScopeRef = { callFrameId: scope.callFrameId, scopeNumber };
const extraProperties: ExtraProperty[] = [];
if (scopeNumber === 0 && scope.chain[scopeNumber].type === 'local') {
if (scopeNumber === 0) {
extraProperties.push({name: 'this', value: scope.thisObject});
if (scope.returnValue)
extraProperties.push({name: localize('scope.returnValue', 'Return value'), value: scope.returnValue});
Expand Down
8 changes: 4 additions & 4 deletions src/test/stacks/stacks-anonymous-scopes.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@

paused @ <eval>/VM<xx>:4:9
> scope #0: paused
> scope #0: Local: paused
y: 'paused'
> this: Window
scope #1: Global [expensive]

chained @ <eval>/VM<xx>:11:23
> scope #0: chained
> scope #0: Local: chained
x: 'x1'
> this: Window
> scope #1: Closure (chain)
n: 1
scope #2: Global [expensive]

chained @ <eval>/VM<xx>:11:23
> scope #0: chained
> scope #0: Local: chained
x: 'x2'
> this: Window
> scope #1: Closure (chain)
n: 2
scope #2: Global [expensive]

chained @ <eval>/VM<xx>:11:23
> scope #0: chained
> scope #0: Local: chained
x: 'x3'
> this: Window
> scope #1: Closure (chain)
Expand Down
4 changes: 2 additions & 2 deletions src/test/stacks/stacks-async-disables.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

foo @ <eval>/VM<xx>:4:11
> scope #0: foo
> scope #0: Local: foo
n: 0
> this: Window
scope #1: Global [expensive]

bar @ <eval>/VM<xx>:13:15
> scope #0: bar
> scope #0: Local: bar
n: 0
> this: Window
scope #1: Global [expensive]
4 changes: 2 additions & 2 deletions src/test/stacks/stacks-async.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

foo @ <eval>/VM<xx>:4:11
> scope #0: foo
> scope #0: Local: foo
n: 0
> this: Window
scope #1: Global [expensive]

bar @ <eval>/VM<xx>:13:15
> scope #0: bar
> scope #0: Local: bar
n: 0
> this: Window
scope #1: Global [expensive]
Expand Down
2 changes: 0 additions & 2 deletions src/test/stacks/stacks-blackboxed.txt

This file was deleted.

2 changes: 1 addition & 1 deletion src/test/stacks/stacks-return-value.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

foo @ <eval>/VM<xx>:4:19
> scope #0: foo
> scope #0: Local: foo
> this: Window
Return value: 42
scope #1: Global [expensive]
Expand Down
10 changes: 5 additions & 5 deletions src/test/stacks/stacks-source-map.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

foo @ ${workspaceFolder}/web/browserify/module1.ts:3:2
> scope #0: foo
> scope #0: Local: foo
this: undefined
scope #1: Global [expensive]

bar @ ${workspaceFolder}/web/browserify/module2.ts:3:2
> scope #0: bar
> scope #0: Local: bar

> callback: ƒ foo() {
debugger;
Expand All @@ -14,7 +14,7 @@ bar @ ${workspaceFolder}/web/browserify/module2.ts:3:2
scope #1: Global [expensive]

3../module1 @ ${workspaceFolder}/web/browserify/pause.ts:4:3
> scope #0: 3../module1
> scope #0: Local: 3../module1
> exports: {__esModule: true}
> m1: {__esModule: true, kModule1: 1, foo: ƒ, throwError: ƒ, throwValue: ƒ}
> m2: {__esModule: true, kModule2: 2, bar: ƒ, pause: ƒ}
Expand All @@ -24,7 +24,7 @@ bar @ ${workspaceFolder}/web/browserify/module2.ts:3:2
scope #1: Global [expensive]

o @ ${workspaceFolder}/node_modules/browser-pack/_prelude.js:1:1
> scope #0: o
> scope #0: Local: o
a: undefined
c: undefined
f: undefined
Expand All @@ -42,7 +42,7 @@ o @ ${workspaceFolder}/node_modules/browser-pack/_prelude.js:1:1
scope #3: Global [expensive]

r @ ${workspaceFolder}/node_modules/browser-pack/_prelude.js:1:1
> scope #0: r
> scope #0: Local: r
> e: {1: Array(2), 2: Array(2), 3: Array(2)}
i: 0
> n: {1: {…}, 2: {…}, 3: {…}}
Expand Down
1 change: 0 additions & 1 deletion src/test/stacks/stacks-stack-in-eval.txt

This file was deleted.

4 changes: 2 additions & 2 deletions src/test/variables/variables-setvariable-scope.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ stopped: {
reason : pause
threadId : <number>
}
> scope: foo
> scope: Local: foo
y: 'value of y'
z: 'value of z'
> this: Window
Expand All @@ -13,7 +13,7 @@ Setting "y" to "z"
<result>: 'value of z'

Original
> scope: foo
> scope: Local: foo
y: 'value of z'
z: 'value of z'
> this: Window

0 comments on commit 0a41897

Please sign in to comment.