Skip to content

Commit 812472e

Browse files
committed
inline values: better update on model change
1 parent a1494ab commit 812472e

1 file changed

Lines changed: 26 additions & 28 deletions

File tree

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

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ export class DebugEditorContribution implements IDebugEditorContribution {
176176
this.hideHoverWidget();
177177
this.updateConfigurationWidgetVisibility();
178178
this.wordToLineNumbersMap = null;
179+
this.updateInlineDecorations(sf);
179180
}));
180181
this.toDispose.push(this.editor.onDidScrollChange(() => this.hideHoverWidget));
181182
}
@@ -218,9 +219,7 @@ export class DebugEditorContribution implements IDebugEditorContribution {
218219
this.hideHoverWidget();
219220
}
220221

221-
if (this.configurationService.getConfiguration<IDebugConfiguration>('debug').inlineValues) {
222-
this.updateInlineDecorators(sf);
223-
}
222+
this.updateInlineDecorations(sf);
224223
}
225224

226225
private hideHoverWidget(): void {
@@ -348,9 +347,10 @@ export class DebugEditorContribution implements IDebugEditorContribution {
348347
};
349348

350349
// Inline Decorations
351-
352-
private updateInlineDecorators(stackFrame: IStackFrame): void {
353-
if (!stackFrame) {
350+
private updateInlineDecorations(stackFrame: IStackFrame): void {
351+
const model = this.editor.getModel();
352+
if (!this.configurationService.getConfiguration<IDebugConfiguration>('debug').inlineValues ||
353+
!model || !stackFrame || model.uri.toString() !== stackFrame.source.uri.toString()) {
354354
if (!this.removeInlineValuesScheduler.isScheduled()) {
355355
this.removeInlineValuesScheduler.schedule();
356356
}
@@ -443,33 +443,31 @@ export class DebugEditorContribution implements IDebugEditorContribution {
443443
if (!this.wordToLineNumbersMap) {
444444
this.wordToLineNumbersMap = new Map<string, number[]>();
445445
const model = this.editor.getModel();
446-
if (model) {
447-
// For every word in every line, map its ranges for fast lookup
448-
for (let lineNumber = 1, len = model.getLineCount(); lineNumber <= len; ++lineNumber) {
449-
const lineContent = model.getLineContent(lineNumber);
450-
451-
// If line is too long then skip the line
452-
if (lineContent.length > MAX_TOKENIZATION_LINE_LEN) {
453-
continue;
454-
}
446+
// For every word in every line, map its ranges for fast lookup
447+
for (let lineNumber = 1, len = model.getLineCount(); lineNumber <= len; ++lineNumber) {
448+
const lineContent = model.getLineContent(lineNumber);
455449

456-
const lineTokens = model.getLineTokens(lineNumber);
457-
for (let token = lineTokens.firstToken(); !!token; token = token.next()) {
458-
const tokenStr = lineContent.substring(token.startOffset, token.endOffset);
450+
// If line is too long then skip the line
451+
if (lineContent.length > MAX_TOKENIZATION_LINE_LEN) {
452+
continue;
453+
}
459454

460-
// Token is a word and not a comment
461-
if (token.tokenType === StandardTokenType.Other) {
462-
DEFAULT_WORD_REGEXP.lastIndex = 0; // We assume tokens will usually map 1:1 to words if they match
463-
const wordMatch = DEFAULT_WORD_REGEXP.exec(tokenStr);
455+
const lineTokens = model.getLineTokens(lineNumber);
456+
for (let token = lineTokens.firstToken(); !!token; token = token.next()) {
457+
const tokenStr = lineContent.substring(token.startOffset, token.endOffset);
464458

465-
if (wordMatch) {
466-
const word = wordMatch[0];
467-
if (!this.wordToLineNumbersMap.has(word)) {
468-
this.wordToLineNumbersMap.set(word, []);
469-
}
459+
// Token is a word and not a comment
460+
if (token.tokenType === StandardTokenType.Other) {
461+
DEFAULT_WORD_REGEXP.lastIndex = 0; // We assume tokens will usually map 1:1 to words if they match
462+
const wordMatch = DEFAULT_WORD_REGEXP.exec(tokenStr);
470463

471-
this.wordToLineNumbersMap.get(word).push(lineNumber);
464+
if (wordMatch) {
465+
const word = wordMatch[0];
466+
if (!this.wordToLineNumbersMap.has(word)) {
467+
this.wordToLineNumbersMap.set(word, []);
472468
}
469+
470+
this.wordToLineNumbersMap.get(word).push(lineNumber);
473471
}
474472
}
475473
}

0 commit comments

Comments
 (0)