Skip to content

Commit 0364ab0

Browse files
authored
Fix issue with Rename UI lingering after cancellation (#12796)
1 parent 911c04b commit 0364ab0

File tree

3 files changed

+22
-29
lines changed

3 files changed

+22
-29
lines changed

Diff for: Extension/src/LanguageServer/Providers/callHierarchyProvider.ts

+10-19
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,6 @@ export interface CallHierarchyParams {
5151

5252
interface CallHierarchyItemResult {
5353
item?: CallHierarchyItem;
54-
55-
/**
56-
* If a request is cancelled, `succeeded` will be undefined to indicate no result was returned.
57-
* Therefore, object is not defined as optional on the language server.
58-
*/
59-
succeeded: boolean;
6054
}
6155

6256
interface CallHierarchyCallsItem {
@@ -137,25 +131,23 @@ export class CallHierarchyProvider implements vscode.CallHierarchyProvider {
137131
}
138132
throw e;
139133
}
140-
cancellationTokenListener.dispose();
141-
requestCanceledListener.dispose();
134+
finally {
135+
cancellationTokenListener.dispose();
136+
requestCanceledListener.dispose();
137+
}
142138

143-
if (cancelSource.token.isCancellationRequested || response.succeeded === undefined) {
144-
// Return undefined instead of vscode.CancellationError to avoid the following error message from VS Code:
145-
// "MISSING provider."
146-
// TODO: per issue https://github.com/microsoft/vscode/issues/169698 vscode.CancellationError is expected,
147-
// so when VS Code fixes the error use vscode.CancellationError again.
148-
return undefined;
149-
} else if (response.item === undefined) {
139+
if (cancelSource.token.isCancellationRequested) {
140+
throw new vscode.CancellationError();
141+
}
142+
if (response.item === undefined) {
150143
return undefined;
151144
}
152145

153146
this.isEntryRootNodeTelemetry = true;
154147
return this.makeVscodeCallHierarchyItem(response.item);
155148
}
156149

157-
public async provideCallHierarchyIncomingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken):
158-
Promise<vscode.CallHierarchyIncomingCall[] | undefined> {
150+
public async provideCallHierarchyIncomingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyIncomingCall[] | undefined> {
159151
await this.client.ready;
160152
workspaceReferences.cancelCurrentReferenceRequest(CancellationSender.NewRequest);
161153

@@ -215,8 +207,7 @@ export class CallHierarchyProvider implements vscode.CallHierarchyProvider {
215207
return result;
216208
}
217209

218-
public async provideCallHierarchyOutgoingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken):
219-
Promise<vscode.CallHierarchyOutgoingCall[] | undefined> {
210+
public async provideCallHierarchyOutgoingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyOutgoingCall[] | undefined> {
220211
const CallHierarchyCallsFromEvent: string = "CallHierarchyCallsFrom";
221212
if (item === undefined) {
222213
this.logTelemetry(CallHierarchyCallsFromEvent, CallHierarchyRequestStatus.Failed);

Diff for: Extension/src/LanguageServer/Providers/findAllReferencesProvider.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ export class FindAllReferencesProvider implements vscode.ReferenceProvider {
4545
throw e;
4646
}
4747
}
48-
49-
// Reset anything that can be cleared before processing the result.
50-
workspaceReferences.resetProgressBar();
51-
cancellationTokenListener.dispose();
52-
requestCanceledListener.dispose();
48+
finally {
49+
// Reset anything that can be cleared before processing the result.
50+
workspaceReferences.resetProgressBar();
51+
cancellationTokenListener.dispose();
52+
requestCanceledListener.dispose();
53+
}
5354

5455
// Process the result.
5556
if (cancelSource.token.isCancellationRequested || cancelled || (response && response.isCanceled)) {

Diff for: Extension/src/LanguageServer/Providers/renameProvider.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@ export class RenameProvider implements vscode.RenameProvider {
5757
}
5858
throw e;
5959
}
60-
61-
// Reset anything that can be cleared before processing the result.
62-
workspaceReferences.resetProgressBar();
63-
workspaceReferences.resetReferences();
64-
requestCanceledListener.dispose();
60+
finally {
61+
// Reset anything that can be cleared before processing the result.
62+
workspaceReferences.resetProgressBar();
63+
workspaceReferences.resetReferences();
64+
requestCanceledListener.dispose();
65+
}
6566

6667
// Process the result.
6768
if (cancelSource.token.isCancellationRequested || response.isCanceled) {

0 commit comments

Comments
 (0)