Partial fix for ExtHost CodeLenses registering commands after they have already been disposed of

For #75105

This change ensures that we do not try registering a command while resolving a code lens. However it does not fix the issue where we can end up trying to invoke a command that has already been disposed of
This commit is contained in:
Matt Bierner
2019-06-07 18:19:35 -07:00
parent f16e33cf13
commit 1e9fae2fba

View File

@@ -145,8 +145,7 @@ class CodeLensAdapter {
resolveCodeLens(symbol: CodeLensDto, token: CancellationToken): Promise<CodeLensDto | undefined> {
const lens = symbol.cacheId && this._cache.get(...symbol.cacheId);
const disposables = symbol.cacheId && this._disposables.get(symbol.cacheId[0]);
if (!lens || !disposables) {
if (!lens) {
return Promise.resolve(undefined);
}
@@ -158,6 +157,16 @@ class CodeLensAdapter {
}
return resolve.then(newLens => {
if (token.isCancellationRequested) {
return undefined;
}
const disposables = symbol.cacheId && this._disposables.get(symbol.cacheId[0]);
if (!disposables) {
// We've already been disposed of
return undefined;
}
newLens = newLens || lens;
symbol.command = this._commands.toInternal2(newLens.command || CodeLensAdapter._badCmd, disposables);
return symbol;