Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark progress bars as cancellable where it appears we are respecting the token #3517

Merged
merged 6 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions extensions/ql-vscode/src/databases/local-databases-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@ export class DatabaseUI extends DisposableObject {
},
{
title: "Clearing cache",
cancellable: true,
robertbrignull marked this conversation as resolved.
Show resolved Hide resolved
},
);
}
Expand All @@ -692,6 +693,7 @@ export class DatabaseUI extends DisposableObject {
},
{
title: "Trimming cache",
cancellable: true,
},
);
}
Expand Down
1 change: 1 addition & 0 deletions extensions/ql-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ function getCommands(
},
{
title: "Restarting Query Server",
cancellable: true,
robertbrignull marked this conversation as resolved.
Show resolved Hide resolved
},
);

Expand Down
97 changes: 50 additions & 47 deletions extensions/ql-vscode/src/model-editor/model-editor-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -810,57 +810,60 @@ export class ModelEditorView extends AbstractWebview<
}

private async modelDependency(): Promise<void> {
return withProgress(async (progress, token) => {
const addedDatabase =
await this.promptChooseNewOrExistingDatabase(progress);
if (!addedDatabase || token.isCancellationRequested) {
return;
}
return withProgress(
async (progress, token) => {
const addedDatabase =
await this.promptChooseNewOrExistingDatabase(progress);
if (!addedDatabase || token.isCancellationRequested) {
return;
}

const addedDbUri = addedDatabase.databaseUri.toString();
if (this.modelingStore.isDbOpen(addedDbUri)) {
this.modelingEvents.fireFocusModelEditorEvent(addedDbUri);
return;
}
const addedDbUri = addedDatabase.databaseUri.toString();
if (this.modelingStore.isDbOpen(addedDbUri)) {
this.modelingEvents.fireFocusModelEditorEvent(addedDbUri);
return;
}

const modelFile = await pickExtensionPack(
this.cliServer,
addedDatabase,
this.modelConfig,
this.app.logger,
progress,
token,
3,
);
if (!modelFile) {
return;
}
const modelFile = await pickExtensionPack(
this.cliServer,
addedDatabase,
this.modelConfig,
this.app.logger,
progress,
token,
3,
);
if (!modelFile) {
return;
}

// Check again just before opening the editor to ensure no model editor has been opened between
// our first check and now.
if (this.modelingStore.isDbOpen(addedDbUri)) {
this.modelingEvents.fireFocusModelEditorEvent(addedDbUri);
return;
}
// Check again just before opening the editor to ensure no model editor has been opened between
// our first check and now.
if (this.modelingStore.isDbOpen(addedDbUri)) {
this.modelingEvents.fireFocusModelEditorEvent(addedDbUri);
return;
}

const view = new ModelEditorView(
this.app,
this.modelingStore,
this.modelingEvents,
this.modelConfig,
this.databaseManager,
this.variantAnalysisManager,
this.cliServer,
this.queryRunner,
this.queryStorageDir,
this.queryDir,
addedDatabase,
modelFile,
this.language,
Mode.Framework,
);
await view.openView();
});
const view = new ModelEditorView(
this.app,
this.modelingStore,
this.modelingEvents,
this.modelConfig,
this.databaseManager,
this.variantAnalysisManager,
this.cliServer,
this.queryRunner,
this.queryStorageDir,
this.queryDir,
addedDatabase,
modelFile,
this.language,
Mode.Framework,
);
await view.openView();
},
{ cancellable: true },
);
}

private async promptChooseNewOrExistingDatabase(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export class QueryServerClient extends DisposableObject {
this.restartQueryServerInternal(progress, token),
{
title: "Restarting CodeQL query server due to unexpected termination",
cancellable: true,
robertbrignull marked this conversation as resolved.
Show resolved Hide resolved
},
);
} else {
Expand Down
Loading