I am working on VS code extension, where I have a global variable which has the value of the working directory and set and get functions to modify or to get it.
One of the functionality of the extension is to open the folder with the saved directory, however after opening it , the global value of the currentDirectcry
is set to ‘NULL’ again
let currentDirectory = "";
function getCurrentDirectory() {
return currentDirectory;
}
function setCurrentDirectory(dir) {
currentDirectory = dir;
function openFolder(folderPath) {
return vscode.workspace.updateWorkspaceFolders(null, vscode.Uri.file(folderPath));
}
After calling openFolder()
, the getCurrentDirectory()
returns NULL
although it returns correct value before opening the folder
How can I guard the global variable when opening new project/folder?