Skip to content

Commit 1e9fae2

Browse files
committed
Partial fix for ExtHost CodeLenses registering commands after they have already been disposed of
For microsoft#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
1 parent f16e33c commit 1e9fae2

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/vs/workbench/api/common/extHostLanguageFeatures.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ class CodeLensAdapter {
145145
resolveCodeLens(symbol: CodeLensDto, token: CancellationToken): Promise<CodeLensDto | undefined> {
146146

147147
const lens = symbol.cacheId && this._cache.get(...symbol.cacheId);
148-
const disposables = symbol.cacheId && this._disposables.get(symbol.cacheId[0]);
149-
if (!lens || !disposables) {
148+
if (!lens) {
150149
return Promise.resolve(undefined);
151150
}
152151

@@ -158,6 +157,16 @@ class CodeLensAdapter {
158157
}
159158

160159
return resolve.then(newLens => {
160+
if (token.isCancellationRequested) {
161+
return undefined;
162+
}
163+
164+
const disposables = symbol.cacheId && this._disposables.get(symbol.cacheId[0]);
165+
if (!disposables) {
166+
// We've already been disposed of
167+
return undefined;
168+
}
169+
161170
newLens = newLens || lens;
162171
symbol.command = this._commands.toInternal2(newLens.command || CodeLensAdapter._badCmd, disposables);
163172
return symbol;

0 commit comments

Comments
 (0)