Skip to content

Commit b6fdf09

Browse files
committed
foxes microsoft#4648: [codelens] Uncaught TypeError: Cannot read property 'symbol' of undefined
1 parent a0ead9a commit b6fdf09

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/vs/editor/contrib/codelens/browser/codelens.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,18 @@ class CodeLens {
279279
});
280280
}
281281

282-
public updateCodeLensSymbols(data: ICodeLensData[]): void {
282+
public updateCodeLensSymbols(data: ICodeLensData[], helper: CodeLensHelper): void {
283+
while (this._decorationIds.length) {
284+
helper.removeDecoration(this._decorationIds.pop());
285+
}
283286
this._data = data;
287+
this._decorationIds = new Array<string>(this._data.length);
288+
this._data.forEach((codeLensData, i) => {
289+
helper.addDecoration({
290+
range: codeLensData.symbol.range,
291+
options: {}
292+
}, id => this._decorationIds[i] = id);
293+
});
284294
}
285295

286296
public computeIfNecessary(currentModelsVersionId: number, model: editorCommon.IModel): ICodeLensData[] {
@@ -556,7 +566,7 @@ export class CodeLensContribution implements editorCommon.IEditorContribution {
556566
this._lenses[codeLensIndex].dispose(helper, accessor);
557567
this._lenses.splice(codeLensIndex, 1);
558568
} else if (codeLensLineNumber === symbolsLineNumber) {
559-
this._lenses[codeLensIndex].updateCodeLensSymbols(groups[groupsIndex]);
569+
this._lenses[codeLensIndex].updateCodeLensSymbols(groups[groupsIndex], helper);
560570
groupsIndex++;
561571
codeLensIndex++;
562572
} else {

0 commit comments

Comments
 (0)