Skip to content

Commit

Permalink
Fix issue with Rename UI lingering after cancellation (#12796)
Browse files Browse the repository at this point in the history
  • Loading branch information
Colengms authored Oct 2, 2024
1 parent 911c04b commit 0364ab0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 29 deletions.
29 changes: 10 additions & 19 deletions Extension/src/LanguageServer/Providers/callHierarchyProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ export interface CallHierarchyParams {

interface CallHierarchyItemResult {
item?: CallHierarchyItem;

/**
* If a request is cancelled, `succeeded` will be undefined to indicate no result was returned.
* Therefore, object is not defined as optional on the language server.
*/
succeeded: boolean;
}

interface CallHierarchyCallsItem {
Expand Down Expand Up @@ -137,25 +131,23 @@ export class CallHierarchyProvider implements vscode.CallHierarchyProvider {
}
throw e;
}
cancellationTokenListener.dispose();
requestCanceledListener.dispose();
finally {
cancellationTokenListener.dispose();
requestCanceledListener.dispose();
}

if (cancelSource.token.isCancellationRequested || response.succeeded === undefined) {
// Return undefined instead of vscode.CancellationError to avoid the following error message from VS Code:
// "MISSING provider."
// TODO: per issue https://github.com/microsoft/vscode/issues/169698 vscode.CancellationError is expected,
// so when VS Code fixes the error use vscode.CancellationError again.
return undefined;
} else if (response.item === undefined) {
if (cancelSource.token.isCancellationRequested) {
throw new vscode.CancellationError();
}
if (response.item === undefined) {
return undefined;
}

this.isEntryRootNodeTelemetry = true;
return this.makeVscodeCallHierarchyItem(response.item);
}

public async provideCallHierarchyIncomingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken):
Promise<vscode.CallHierarchyIncomingCall[] | undefined> {
public async provideCallHierarchyIncomingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyIncomingCall[] | undefined> {
await this.client.ready;
workspaceReferences.cancelCurrentReferenceRequest(CancellationSender.NewRequest);

Expand Down Expand Up @@ -215,8 +207,7 @@ export class CallHierarchyProvider implements vscode.CallHierarchyProvider {
return result;
}

public async provideCallHierarchyOutgoingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken):
Promise<vscode.CallHierarchyOutgoingCall[] | undefined> {
public async provideCallHierarchyOutgoingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyOutgoingCall[] | undefined> {
const CallHierarchyCallsFromEvent: string = "CallHierarchyCallsFrom";
if (item === undefined) {
this.logTelemetry(CallHierarchyCallsFromEvent, CallHierarchyRequestStatus.Failed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ export class FindAllReferencesProvider implements vscode.ReferenceProvider {
throw e;
}
}

// Reset anything that can be cleared before processing the result.
workspaceReferences.resetProgressBar();
cancellationTokenListener.dispose();
requestCanceledListener.dispose();
finally {
// Reset anything that can be cleared before processing the result.
workspaceReferences.resetProgressBar();
cancellationTokenListener.dispose();
requestCanceledListener.dispose();
}

// Process the result.
if (cancelSource.token.isCancellationRequested || cancelled || (response && response.isCanceled)) {
Expand Down
11 changes: 6 additions & 5 deletions Extension/src/LanguageServer/Providers/renameProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ export class RenameProvider implements vscode.RenameProvider {
}
throw e;
}

// Reset anything that can be cleared before processing the result.
workspaceReferences.resetProgressBar();
workspaceReferences.resetReferences();
requestCanceledListener.dispose();
finally {
// Reset anything that can be cleared before processing the result.
workspaceReferences.resetProgressBar();
workspaceReferences.resetReferences();
requestCanceledListener.dispose();
}

// Process the result.
if (cancelSource.token.isCancellationRequested || response.isCanceled) {
Expand Down

0 comments on commit 0364ab0

Please sign in to comment.