Skip to content

Commit ef6b3de

Browse files
committed
inlineValues: respect stackFrame lineNumber and column
1 parent 812472e commit ef6b3de

1 file changed

Lines changed: 26 additions & 18 deletions

File tree

src/vs/workbench/parts/debug/electron-browser/debugEditorContribution.ts

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class DebugEditorContribution implements IDebugEditorContribution {
5656
private breakpointHintDecoration: string[];
5757
private breakpointWidget: BreakpointWidget;
5858
private breakpointWidgetVisible: IContextKey<boolean>;
59-
private wordToLineNumbersMap: Map<string, number[]>;
59+
private wordToLineNumbersMap: Map<string, IPosition[]>;
6060

6161
private configurationWidget: FloatingClickWidget;
6262

@@ -361,15 +361,21 @@ export class DebugEditorContribution implements IDebugEditorContribution {
361361

362362
stackFrame.getScopes()
363363
// Get all top level children in the scope chain
364-
.then(scopes => TPromise.join(scopes.map(scope => scope.getChildren())))
365-
.then(children => {
366-
const expressions = children.reduce((previous, current) => previous.concat(current), []);
367-
const decorations = this.createAllInlineValueDecorations(expressions);
368-
this.editor.setDecorations(INLINE_VALUE_DECORATION_KEY, decorations);
369-
});
364+
.then(scopes => TPromise.join(scopes.filter(s => !s.expensive).map(scope => scope.getChildren()
365+
.then(children => {
366+
let range = new Range(0, 0, stackFrame.lineNumber, stackFrame.column);
367+
if (scope.range) {
368+
range = range.setStartPosition(scope.range.startLineNumber, scope.range.startColumn);
369+
}
370+
371+
return this.createInlineValueDecorationsInsideRange(children, range);
372+
}))).then(decorationsPerScope => {
373+
const allDecorations = decorationsPerScope.reduce((previous, current) => previous.concat(current), []);
374+
this.editor.setDecorations(INLINE_VALUE_DECORATION_KEY, allDecorations);
375+
}));
370376
}
371377

372-
private createAllInlineValueDecorations(expressions: IExpression[]): IDecorationOptions[] {
378+
private createInlineValueDecorationsInsideRange(expressions: IExpression[], range: Range): IDecorationOptions[] {
373379
const nameValueMap = new Map<string, string>();
374380
for (let expr of expressions) {
375381
nameValueMap.set(expr.name, expr.value);
@@ -380,17 +386,19 @@ export class DebugEditorContribution implements IDebugEditorContribution {
380386
}
381387

382388
const lineToNamesMap: Map<number, string[]> = new Map<number, string[]>();
383-
const wordToLineNumbersMap = this.getWordToLineNumbersMap();
389+
const wordToPositionsMap = this.getWordToPositionsMap();
384390

385391
// Compute unique set of names on each line
386392
nameValueMap.forEach((value, name) => {
387-
if (wordToLineNumbersMap.has(name)) {
388-
for (let lineNumber of wordToLineNumbersMap.get(name)) {
389-
if (!lineToNamesMap.has(lineNumber)) {
390-
lineToNamesMap.set(lineNumber, []);
391-
}
393+
if (wordToPositionsMap.has(name)) {
394+
for (let position of wordToPositionsMap.get(name)) {
395+
if (range.containsPosition(position)) {
396+
if (!lineToNamesMap.has(position.lineNumber)) {
397+
lineToNamesMap.set(position.lineNumber, []);
398+
}
392399

393-
lineToNamesMap.get(lineNumber).push(name);
400+
lineToNamesMap.get(position.lineNumber).push(name);
401+
}
394402
}
395403
}
396404
});
@@ -439,9 +447,9 @@ export class DebugEditorContribution implements IDebugEditorContribution {
439447
};
440448
}
441449

442-
private getWordToLineNumbersMap(): Map<string, number[]> {
450+
private getWordToPositionsMap(): Map<string, IPosition[]> {
443451
if (!this.wordToLineNumbersMap) {
444-
this.wordToLineNumbersMap = new Map<string, number[]>();
452+
this.wordToLineNumbersMap = new Map<string, IPosition[]>();
445453
const model = this.editor.getModel();
446454
// For every word in every line, map its ranges for fast lookup
447455
for (let lineNumber = 1, len = model.getLineCount(); lineNumber <= len; ++lineNumber) {
@@ -467,7 +475,7 @@ export class DebugEditorContribution implements IDebugEditorContribution {
467475
this.wordToLineNumbersMap.set(word, []);
468476
}
469477

470-
this.wordToLineNumbersMap.get(word).push(lineNumber);
478+
this.wordToLineNumbersMap.get(word).push({ lineNumber, column: token.startOffset });
471479
}
472480
}
473481
}

0 commit comments

Comments
 (0)