Skip to content

Commit

Permalink
Find the most specific scope containing the range
Browse files Browse the repository at this point in the history
fixes #16632
  • Loading branch information
isidorn committed Dec 22, 2016
1 parent 2e83524 commit 524150b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/vs/workbench/parts/debug/electron-browser/debugHover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,18 @@ export class DebugHoverWidget implements IContentWidget {

private findExpressionInStackFrame(namesToFind: string[], expressionRange: Range): TPromise<IExpression> {
return this.debugService.getViewModel().focusedStackFrame.getScopes()
// no expensive scopes and if a range of scope is defined it needs to contain the variable
.then(scopes => scopes.filter(scope => !scope.expensive && (!scope.range || Range.containsRange(scope.range, expressionRange))))
.then(scopes => scopes.filter(scope => !scope.expensive))
.then(scopes => {
// no expensive scopes and if a range of scope is defined it needs to contain the variable
const haveRangeInfo = scopes.some(s => !!s.range);
if (!haveRangeInfo) {
return scopes;
}

// Find the most specific scope containing the range #16632
return [scopes.filter(scope => Range.containsRange(scope.range, expressionRange))

This comment has been minimized.

Copy link
@f111fei

f111fei Jan 13, 2017

Contributor

scope.range may be undefined

This comment has been minimized.

Copy link
@isidorn

isidorn Jan 13, 2017

Author Contributor

@f111fei thanks! fixed via 4dcbad3

This comment has been minimized.

Copy link
@f111fei

f111fei Jan 13, 2017

Contributor

ok . I will close #18501

.sort((first, second) => (first.range.endLineNumber - first.range.startLineNumber) - (second.range.endLineNumber - second.range.startLineNumber)).shift()];
})
.then(scopes => TPromise.join(scopes.map(scope => this.doFindExpression(scope, namesToFind))))
.then(expressions => expressions.filter(exp => !!exp))
// only show if all expressions found have the same value
Expand Down

0 comments on commit 524150b

Please sign in to comment.