throw when cancelling
This commit is contained in:
@@ -4,6 +4,7 @@ import { Progress, CancellationToken } from "vscode";
|
||||
import { Credentials } from "../common/authentication";
|
||||
import { BaseLogger } from "../common/logging";
|
||||
import { AppOctokit } from "../common/octokit";
|
||||
import { UserCancellationException } from "../common/vscode/progress";
|
||||
|
||||
export async function getCodeSearchRepositories(
|
||||
query: string,
|
||||
@@ -15,7 +16,7 @@ export async function getCodeSearchRepositories(
|
||||
credentials: Credentials,
|
||||
logger: BaseLogger,
|
||||
): Promise<string[]> {
|
||||
let nwos: string[] = [];
|
||||
const nwos: string[] = [];
|
||||
const octokit = await provideOctokitWithThrottling(credentials, logger);
|
||||
|
||||
for await (const response of octokit.paginate.iterator(
|
||||
@@ -34,8 +35,7 @@ export async function getCodeSearchRepositories(
|
||||
progress.report({ increment });
|
||||
|
||||
if (token.isCancellationRequested) {
|
||||
nwos = [];
|
||||
break;
|
||||
throw new UserCancellationException("Code search cancelled.", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,10 +34,7 @@ import { DatabasePanelCommands } from "../../common/commands";
|
||||
import { App } from "../../common/app";
|
||||
import { QueryLanguage } from "../../common/query-language";
|
||||
import { getCodeSearchRepositories } from "../code-search-api";
|
||||
import {
|
||||
showAndLogErrorMessage,
|
||||
showAndLogInformationMessage,
|
||||
} from "../../common/logging";
|
||||
import { showAndLogErrorMessage } from "../../common/logging";
|
||||
|
||||
export interface RemoteDatabaseQuickPickItem extends QuickPickItem {
|
||||
remoteDatabaseKind: string;
|
||||
@@ -426,13 +423,9 @@ export class DbPanel extends DisposableObject {
|
||||
this.app.logger,
|
||||
);
|
||||
|
||||
token.onCancellationRequested(() => {
|
||||
void showAndLogInformationMessage(
|
||||
this.app.logger,
|
||||
"Code search cancelled",
|
||||
);
|
||||
return;
|
||||
});
|
||||
if (token.isCancellationRequested) {
|
||||
throw new UserCancellationException("Code search cancelled.", true);
|
||||
}
|
||||
|
||||
progress.report({ increment: 10, message: "Processing results..." });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user