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.
This commit is contained in:
@@ -295,10 +295,20 @@ export async function prepareCodeTour(): Promise<void> {
|
||||
existsSync(toursFolderPath) &&
|
||||
!isCodespacesTemplate()
|
||||
) {
|
||||
const answer = await showBinaryChoiceDialog(
|
||||
"We've detected you're in the CodeQL Tour repo. We will need to open the workspace file to continue. Reload?",
|
||||
);
|
||||
|
||||
if (!answer) {
|
||||
return;
|
||||
}
|
||||
|
||||
const tutorialWorkspaceUri = Uri.parse(tutorialWorkspacePath);
|
||||
|
||||
void extLogger.log(
|
||||
`In prepareCodeTour() method, going to open the tutorial workspace file: ${tutorialWorkspacePath}`,
|
||||
);
|
||||
|
||||
await commands.executeCommand("vscode.openFolder", tutorialWorkspaceUri);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -572,6 +572,9 @@ describe("isFolderAlreadyInWorkspace", () => {
|
||||
|
||||
describe("prepareCodeTour", () => {
|
||||
let dir: tmp.DirResult;
|
||||
let showInformationMessageSpy: jest.SpiedFunction<
|
||||
typeof window.showInformationMessage
|
||||
>;
|
||||
|
||||
beforeEach(() => {
|
||||
dir = tmp.dirSync();
|
||||
@@ -587,6 +590,10 @@ describe("prepareCodeTour", () => {
|
||||
jest
|
||||
.spyOn(workspace, "workspaceFolders", "get")
|
||||
.mockReturnValue(mockWorkspaceFolders);
|
||||
|
||||
showInformationMessageSpy = jest
|
||||
.spyOn(window, "showInformationMessage")
|
||||
.mockResolvedValue({ title: "Yes" });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -610,6 +617,7 @@ describe("prepareCodeTour", () => {
|
||||
|
||||
await prepareCodeTour();
|
||||
|
||||
expect(showInformationMessageSpy).toHaveBeenCalled();
|
||||
expect(commandSpy).toHaveBeenCalledWith(
|
||||
"vscode.openFolder",
|
||||
Uri.parse(tutorialWorkspacePath),
|
||||
|
||||
Reference in New Issue
Block a user