Skip to content

Commit 0368d53

Browse files
committed
Ask the user for permission to reload workspace
To make this a nicer experience for the user, we're adding a prompt to let them know we're about to reload the workspace.
1 parent 7059802 commit 0368d53

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

extensions/ql-vscode/src/helpers.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,20 @@ export async function prepareCodeTour(): Promise<void> {
295295
existsSync(toursFolderPath) &&
296296
!isCodespacesTemplate()
297297
) {
298+
const answer = await showBinaryChoiceDialog(
299+
"We've detected you're in the CodeQL Tour repo. We will need to open the workspace file to continue. Reload?",
300+
);
301+
302+
if (!answer) {
303+
return;
304+
}
305+
298306
const tutorialWorkspaceUri = Uri.parse(tutorialWorkspacePath);
307+
299308
void extLogger.log(
300309
`In prepareCodeTour() method, going to open the tutorial workspace file: ${tutorialWorkspacePath}`,
301310
);
311+
302312
await commands.executeCommand("vscode.openFolder", tutorialWorkspaceUri);
303313
}
304314
}

extensions/ql-vscode/test/vscode-tests/no-workspace/helpers.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,9 @@ describe("isFolderAlreadyInWorkspace", () => {
572572

573573
describe("prepareCodeTour", () => {
574574
let dir: tmp.DirResult;
575+
let showInformationMessageSpy: jest.SpiedFunction<
576+
typeof window.showInformationMessage
577+
>;
575578

576579
beforeEach(() => {
577580
dir = tmp.dirSync();
@@ -587,6 +590,10 @@ describe("prepareCodeTour", () => {
587590
jest
588591
.spyOn(workspace, "workspaceFolders", "get")
589592
.mockReturnValue(mockWorkspaceFolders);
593+
594+
showInformationMessageSpy = jest
595+
.spyOn(window, "showInformationMessage")
596+
.mockResolvedValue({ title: "Yes" });
590597
});
591598

592599
afterEach(() => {
@@ -610,6 +617,7 @@ describe("prepareCodeTour", () => {
610617

611618
await prepareCodeTour();
612619

620+
expect(showInformationMessageSpy).toHaveBeenCalled();
613621
expect(commandSpy).toHaveBeenCalledWith(
614622
"vscode.openFolder",
615623
Uri.parse(tutorialWorkspacePath),

0 commit comments

Comments
 (0)