From bbb61bf425b7159ae1e669868fe1de9afdc22850 Mon Sep 17 00:00:00 2001 From: JoshwinThomasIBM Date: Fri, 15 Nov 2024 09:03:02 +0530 Subject: [PATCH] updated the message and clear the global states if the user ops not to save the workspace --- src/liberty/devCommands.ts | 2 +- src/liberty/libertyProject.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/liberty/devCommands.ts b/src/liberty/devCommands.ts index b943bda7..f756fbe7 100644 --- a/src/liberty/devCommands.ts +++ b/src/liberty/devCommands.ts @@ -619,7 +619,7 @@ function isWin(): boolean { /* Method adds a project which is selected by the user from the list to the liberty dashboard */ -export async function addProjectsToTheDashBoard(projectProvider : ProjectProvider,selection:string): Promise{ +export async function addProjectsToTheDashBoard(projectProvider : ProjectProvider,selection:string): Promise{ const result = await projectProvider.addUserSelectedPath(selection,projectProvider.getProjects()); const message = localize(`add.project.manually.message.${result}`, selection); (result !== 0) ? console.error(message) : console.info(message); projectProvider.fireChangeEvent(); diff --git a/src/liberty/libertyProject.ts b/src/liberty/libertyProject.ts index c6d8605a..952dfb6e 100644 --- a/src/liberty/libertyProject.ts +++ b/src/liberty/libertyProject.ts @@ -212,16 +212,22 @@ export class ProjectProvider implements vscode.TreeDataProvider return new Promise((resolve) => { try { vscode.window.showInformationMessage( - 'You are currently in an untitled workspace. Would you like to save it?', + 'Please save the workspace first, as manually added projects to the dashboard may not persist in the next VS Code session if the workspace is not saved.', { modal: true }, 'Save Workspace' ).then(async (selection) => { if (selection === 'Save Workspace') { //setting workspaceSaveInProgress to true and storing it in globalstate for identifyting that the workspace is saved and needs to - //save the manually adde projects to the dashboard + //save the manually added projects to the dashboard await this._context.globalState.update('workspaceSaveInProgress',true); //opens the saveWorkspace as dialog box await vscode.commands.executeCommand('workbench.action.saveWorkspaceAs'); + //after execution of above line , if save is opted the workspace reloads and reinitialisation of the workspace happens based on the + //activation events in package.json, if cancel is opted then the workspace is not going to be saved + //so below lines will clear workspaceSaveInProgress and selectedProject from the global state + await this._context.globalState.update('workspaceSaveInProgress',false); + await this._context.globalState.update('selectedProject',undefined); + resolve(); }else { // No workspace save was initiated resolve();