Skip to content

Commit fcbd02c

Browse files
sean-mcmanusCopilot
andcommitted
Update.
Co-authored-by: Copilot <copilot@github.com>
1 parent 1af7443 commit fcbd02c

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

Extension/src/LanguageServer/client.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3024,14 +3024,22 @@ export class DefaultClient implements Client {
30243024
switchHeaderSourceFileName: fileName,
30253025
workspaceFolderUri: rootUri.toString()
30263026
};
3027-
const request: Promise<string> = this.enqueue(async () => {
3027+
return this.enqueue(async () => {
30283028
if (token.isCancellationRequested) {
30293029
throw new vscode.CancellationError();
30303030
}
3031-
return DefaultClient.withLspCancellationHandling(
3032-
() => this.languageClient.sendRequest(SwitchHeaderSourceRequest, params, token), token);
3031+
3032+
// Don't use withLspCancellationHandling() or withCancellation() here. If the switch target is already known,
3033+
// the caller should still be able to use it even if the progress notification was just cancelled.
3034+
try {
3035+
return await this.languageClient.sendRequest(SwitchHeaderSourceRequest, params, token);
3036+
} catch (e: any) {
3037+
if (e instanceof ResponseError && (e.code === RequestCancelled || e.code === ServerCancelled)) {
3038+
throw new vscode.CancellationError();
3039+
}
3040+
throw e;
3041+
}
30333042
});
3034-
return withCancellation(request, token);
30353043
}
30363044

30373045
public async requestCompiler(newCompilerPath?: string): Promise<configs.CompilerDefaults> {

Extension/src/LanguageServer/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ async function onSwitchHeaderSource(): Promise<void> {
481481
const switchHeaderSource: (token: vscode.CancellationToken) => Promise<void> = async (token: vscode.CancellationToken) => {
482482
try {
483483
let targetFileName: string = await clients.ActiveClient.requestSwitchHeaderSource(rootUri, fileName, token);
484-
if (token.isCancellationRequested || !targetFileName) {
484+
if (!targetFileName) {
485485
return;
486486
}
487487
// If the targetFileName has a path that is a symlink target of a workspace folder,

0 commit comments

Comments
 (0)