🎨 add AbortSignal to indexing
This commit is contained in:
parent
3fd0141dba
commit
3eee31a2c4
4 changed files with 19 additions and 1 deletions
|
|
@ -59,6 +59,7 @@ export class CodebaseIndexer {
|
|||
|
||||
async *refresh(
|
||||
workspaceDirs: string[],
|
||||
abortSignal: AbortSignal,
|
||||
): AsyncGenerator<IndexingProgressUpdate> {
|
||||
const config = await this.configHandler.loadConfig();
|
||||
if (config.disableIndexing) {
|
||||
|
|
@ -102,6 +103,13 @@ export class CodebaseIndexer {
|
|||
repoName,
|
||||
)) {
|
||||
// Handle pausing in this loop because it's the only one really taking time
|
||||
if (abortSignal.aborted) {
|
||||
yield {
|
||||
progress: 1,
|
||||
desc: "Indexing cancelled",
|
||||
};
|
||||
return;
|
||||
}
|
||||
while (this.pauseToken.paused) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -258,9 +258,17 @@ export class VsCodeExtension {
|
|||
static continueVirtualDocumentScheme = "continue";
|
||||
|
||||
private PREVIOUS_BRANCH_FOR_WORKSPACE_DIR: { [dir: string]: string } = {};
|
||||
private indexingCancellationController: AbortController | undefined;
|
||||
|
||||
private async refreshCodebaseIndex(dirs: string[]) {
|
||||
for await (const update of this.indexer.refresh(dirs)) {
|
||||
if (this.indexingCancellationController) {
|
||||
this.indexingCancellationController.abort();
|
||||
}
|
||||
this.indexingCancellationController = new AbortController();
|
||||
for await (const update of this.indexer.refresh(
|
||||
dirs,
|
||||
this.indexingCancellationController.signal,
|
||||
)) {
|
||||
this.webviewProtocol.request("indexProgress", update);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@ Alternatively, you can enter your own API keys:
|
|||
});
|
||||
postToIde("openConfigJson", undefined);
|
||||
setLocalStorage("onboardingComplete", true);
|
||||
postToIde("index/forceReIndex", undefined);
|
||||
navigate("/");
|
||||
}}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ function Onboarding() {
|
|||
mode: ["local", "optimized", "custom"][selected] as any,
|
||||
});
|
||||
setLocalStorage("onboardingComplete", true);
|
||||
postToIde("index/forceReIndex", undefined);
|
||||
navigate("/");
|
||||
}}
|
||||
>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue