diff --git a/src/vs/editor/contrib/codelens/codelensController.ts b/src/vs/editor/contrib/codelens/codelensController.ts index a9eb3766de9bb20f1e690d7678ef0e8cee5f16b3..e61b9acafb18e41bada76f9f348ac2c03297202f 100644 --- a/src/vs/editor/contrib/codelens/codelensController.ts +++ b/src/vs/editor/contrib/codelens/codelensController.ts @@ -326,7 +326,7 @@ export class CodeLensContribution implements editorCommon.IEditorContribution { return; } - this._currentResolveCodeLensSymbolsPromise = createCancelablePromise(token => { + const resolvePromise = createCancelablePromise(token => { const promises = toResolve.map((request, i) => { @@ -351,16 +351,21 @@ export class CodeLensContribution implements editorCommon.IEditorContribution { return Promise.all(promises); }); + this._currentResolveCodeLensSymbolsPromise = resolvePromise; this._currentResolveCodeLensSymbolsPromise.then(() => { if (this._currentCodeLensModel) { // update the cached state with new resolved items this._codeLensCache.put(model, this._currentCodeLensModel); } this._oldCodeLensModels.clear(); // dispose old models once we have updated the UI with the current model - this._currentResolveCodeLensSymbolsPromise = undefined; + if (resolvePromise === this._currentResolveCodeLensSymbolsPromise) { + this._currentResolveCodeLensSymbolsPromise = undefined; + } }, err => { onUnexpectedError(err); // can also be cancellation! - this._currentResolveCodeLensSymbolsPromise = undefined; + if (resolvePromise === this._currentResolveCodeLensSymbolsPromise) { + this._currentResolveCodeLensSymbolsPromise = undefined; + } }); } }