Don't drop current code lens promise if the current resolve promise has changed

Fixes #84185
This commit is contained in:
Matt Bierner
2019-11-08 16:25:29 -08:00
parent 696465bddd
commit 8327d3fa95
@@ -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;
}
});
}
}