Skip to content

Commit 934ed82

Browse files
authored
Don't create QL pack if user escapes out of prompt (#3062)
1 parent bc2847a commit 934ed82

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

extensions/ql-vscode/src/common/vscode/workspace-folders.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ export function getFirstWorkspaceFolder() {
4343
const workspaceFolders = getOnDiskWorkspaceFolders();
4444

4545
if (!workspaceFolders || workspaceFolders.length === 0) {
46-
throw new Error("No workspace folders found");
46+
throw new Error(
47+
"No workspace folders found. Please open a folder or workspace in VS Code.",
48+
);
4749
}
4850

4951
const firstFolderFsPath = workspaceFolders[0];

extensions/ql-vscode/src/databases/local-databases/database-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ export class DatabaseManager extends DisposableObject {
265265
`We've noticed you don't have a CodeQL pack available to analyze this database. Can we set up a query pack for you?`,
266266
);
267267

268-
if (answer === "No") {
268+
if (answer === "No" || answer === undefined) {
269269
return;
270270
}
271271

extensions/ql-vscode/test/vscode-tests/minimal-workspace/local-queries/local-databases.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,16 @@ describe("local databases", () => {
622622
expect(generateSpy).not.toBeCalled();
623623
});
624624

625+
it("should return early if the user escapes out of the dialog", async () => {
626+
showNeverAskAgainDialogSpy = jest
627+
.spyOn(dialog, "showNeverAskAgainDialog")
628+
.mockResolvedValue(undefined);
629+
630+
await (databaseManager as any).createSkeletonPacks(mockDbItem);
631+
632+
expect(generateSpy).not.toBeCalled();
633+
});
634+
625635
it("should return early and write choice to settings if user wants to never be asked again", async () => {
626636
showNeverAskAgainDialogSpy = jest
627637
.spyOn(dialog, "showNeverAskAgainDialog")

0 commit comments

Comments
 (0)