提交 812472eb 编写于 作者: I isidor

inline values: better update on model change

上级 a1494abb
......@@ -176,6 +176,7 @@ export class DebugEditorContribution implements IDebugEditorContribution {
this.hideHoverWidget();
this.updateConfigurationWidgetVisibility();
this.wordToLineNumbersMap = null;
this.updateInlineDecorations(sf);
}));
this.toDispose.push(this.editor.onDidScrollChange(() => this.hideHoverWidget));
}
......@@ -218,9 +219,7 @@ export class DebugEditorContribution implements IDebugEditorContribution {
this.hideHoverWidget();
}
if (this.configurationService.getConfiguration<IDebugConfiguration>('debug').inlineValues) {
this.updateInlineDecorators(sf);
}
this.updateInlineDecorations(sf);
}
private hideHoverWidget(): void {
......@@ -348,9 +347,10 @@ export class DebugEditorContribution implements IDebugEditorContribution {
};
// Inline Decorations
private updateInlineDecorators(stackFrame: IStackFrame): void {
if (!stackFrame) {
private updateInlineDecorations(stackFrame: IStackFrame): void {
const model = this.editor.getModel();
if (!this.configurationService.getConfiguration<IDebugConfiguration>('debug').inlineValues ||
!model || !stackFrame || model.uri.toString() !== stackFrame.source.uri.toString()) {
if (!this.removeInlineValuesScheduler.isScheduled()) {
this.removeInlineValuesScheduler.schedule();
}
......@@ -443,33 +443,31 @@ export class DebugEditorContribution implements IDebugEditorContribution {
if (!this.wordToLineNumbersMap) {
this.wordToLineNumbersMap = new Map<string, number[]>();
const model = this.editor.getModel();
if (model) {
// For every word in every line, map its ranges for fast lookup
for (let lineNumber = 1, len = model.getLineCount(); lineNumber <= len; ++lineNumber) {
const lineContent = model.getLineContent(lineNumber);
// If line is too long then skip the line
if (lineContent.length > MAX_TOKENIZATION_LINE_LEN) {
continue;
}
// For every word in every line, map its ranges for fast lookup
for (let lineNumber = 1, len = model.getLineCount(); lineNumber <= len; ++lineNumber) {
const lineContent = model.getLineContent(lineNumber);
const lineTokens = model.getLineTokens(lineNumber);
for (let token = lineTokens.firstToken(); !!token; token = token.next()) {
const tokenStr = lineContent.substring(token.startOffset, token.endOffset);
// If line is too long then skip the line
if (lineContent.length > MAX_TOKENIZATION_LINE_LEN) {
continue;
}
// Token is a word and not a comment
if (token.tokenType === StandardTokenType.Other) {
DEFAULT_WORD_REGEXP.lastIndex = 0; // We assume tokens will usually map 1:1 to words if they match
const wordMatch = DEFAULT_WORD_REGEXP.exec(tokenStr);
const lineTokens = model.getLineTokens(lineNumber);
for (let token = lineTokens.firstToken(); !!token; token = token.next()) {
const tokenStr = lineContent.substring(token.startOffset, token.endOffset);
if (wordMatch) {
const word = wordMatch[0];
if (!this.wordToLineNumbersMap.has(word)) {
this.wordToLineNumbersMap.set(word, []);
}
// Token is a word and not a comment
if (token.tokenType === StandardTokenType.Other) {
DEFAULT_WORD_REGEXP.lastIndex = 0; // We assume tokens will usually map 1:1 to words if they match
const wordMatch = DEFAULT_WORD_REGEXP.exec(tokenStr);
this.wordToLineNumbersMap.get(word).push(lineNumber);
if (wordMatch) {
const word = wordMatch[0];
if (!this.wordToLineNumbersMap.has(word)) {
this.wordToLineNumbersMap.set(word, []);
}
this.wordToLineNumbersMap.get(word).push(lineNumber);
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册