From 5d214db5cc39a6876818ab0c1853d1e9ac805c55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denny=20Korsuk=C3=A9witz?= Date: Thu, 14 Sep 2023 21:32:35 +0200 Subject: [PATCH] Prepared Release. [1.1.1] - `AddFolderToWorkspace: Add manually a directory...` - Paths can be added manually from now on. After that, the new workspace can be saved directly in the settings. - Fixed bug - when a workspace has already been added. --- CHANGELOG.md | 6 +++++ RELEASE.md | 17 +++----------- package.json | 2 +- src/extension.js | 59 +++++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 66 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d37933..9a6ee58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to the "AddFolderToWorkspace" extension will be documented in this file. +## [1.1.1] + +`AddFolderToWorkspace: Add manually a directory...` - Paths can be added manually from now on. After that, the new workspace can be saved directly in the settings.s + +Fixed bug - when a workspace has already been added. + ## [1.1.0] ### AddFolderToWorkspace diff --git a/RELEASE.md b/RELEASE.md index 4ec8b0f..33befce 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,15 +1,4 @@ -# [1.1.0] +# [1.1.1] -## AddFolderToWorkspace - -This Function provides a searchable list of folders (Workspaces) that can be added **simultaneous** to the current VSC Workspace. All configured folders will be displayed. - -**Shortcut:** ```strg + alt + k, p```
-**Command:** ```AddFolderToWorkspace: Add Folder to Workspace.``` - -## RemoveFolderFromWorkspace - -This Function provides a searchable list of folders (Workspaces) that can be removed **simultaneous** from the current VSC Workspace. All current open folders are displayed. - -**Shortcut:** ```strg + alt + k, shift + p```
-**Command:** ```AddFolderToWorkspace: Remove Folder from Workspace.``` +- `AddFolderToWorkspace: Add manually a directory...` - Paths can be added manually from now on. After that, the new workspace can be saved directly in the settings. +- Fixed bug - when a workspace has already been added. \ No newline at end of file diff --git a/package.json b/package.json index 3703c55..694b463 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "AddFolderToWorkspace", "displayName": "Add Folder To Workspace", "description": "This extension adds / removes the selected folder (multiple) to / from the workspace (VSC Workspace).", - "version": "1.1.0", + "version": "1.1.1", "publisher": "dennykorsukewitz", "icon": "doc/images/icon.png", "license": "SEE LICENSE IN LICENSE", diff --git a/src/extension.js b/src/extension.js index 0548a8b..d781edc 100644 --- a/src/extension.js +++ b/src/extension.js @@ -24,7 +24,11 @@ function initAddFolderToWorkspace(context) { const addFolderToWorkspaceId = 'addFolderToWorkspace'; context.subscriptions.push(vscode.commands.registerCommand(addFolderToWorkspaceId, async () => { - let workspaceDirectories = []; + let workspaceDirectories = [], + newWorkspaceFound = 0, + manualWorkspace = '', + manualDirectoryString = '-- Add manually a directory --'; + let config = vscode.workspace.getConfiguration('addFolderToWorkspace'); // Check if workspaces are defined. @@ -50,26 +54,75 @@ function initAddFolderToWorkspace(context) { return; } + if (workspaceDirectories.length && !workspaceDirectories.includes(manualDirectoryString)) { + workspaceDirectories.unshift(manualDirectoryString); + } + // Open QuickPick and add selected Folder (Directory to VSC Workspace). let workspaces = await vscode.window.showQuickPick(workspaceDirectories, { title: 'AddFolderToWorkspace', placeHolder: 'AddFolderToWorkspace: Select a folder...', canPickMany: true, }) + if (!workspaces) return; + + if (workspaces.length && workspaces.includes(manualDirectoryString)) { + workspaces.shift(manualDirectoryString); + newWorkspaceFound = 1; + + manualWorkspace = await vscode.window.showInputBox({ + title: 'AddFolderToWorkspace', + placeHolder: 'AddFolderToWorkspace: Add manually a directory...', + }); + + if (manualWorkspace){ + workspaces.push(manualWorkspace); + } + } if (!workspaces) return; let workspaceURIs = []; for await (const workspace of workspaces) { // Get URI of selected directory. - let URI = vscode.Uri.file(workspace); + let URI = vscode.Uri.file(workspace), + URIexists = 0; + if (!URI) return; - workspaceURIs.push({ uri: URI }); + + vscode.workspace.workspaceFolders.sort().forEach(function (workspaceFolder) { + + if (URI.path == workspaceFolder.uri.path){ + URIexists = 1; + } + }) + + if (!URIexists){ + workspaceURIs.push({ uri: URI }); + } } if (!workspaceURIs.length) return; + if (newWorkspaceFound) { + let addNewWorkspaceToConfig = await vscode.window.showQuickPick(['yes','no'], { + title: 'AddFolderToWorkspace (New Workspace)', + placeHolder: 'AddFolderToWorkspace: Should I save the new workspace in the settings?', + canPickMany: false, + }); + + if (addNewWorkspaceToConfig == 'yes'){ + + if (!manualWorkspace.endsWith("/")){ + manualWorkspace += '/'; + } + + config.workspaces.push(manualWorkspace); + await vscode.workspace.getConfiguration().update('addFolderToWorkspace.workspaces', config.workspaces); + } + } + // Add selected Folder to Workspace. await updateWorkspaceAndWait(0, null, workspaceURIs);