Skip to content

Commit 8243085

Browse files
committed
Allow WorkspacePaths to be empty if we're not in a workspace
We were previously adding the initial working directory as a fallback if there was no workspace. However, this led to new VS Code windows (not in a workspace) enumerating all files in the home directory (if that's what the client had to default to, without a workspace folder). And this could even spam permission requests on more secure systems such as macOS. So we just need to let be an empty enumerable.
1 parent a691981 commit 8243085

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/PowerShellEditorServices/Services/Extension/EditorOperationsService.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ public async Task SaveFileAsync(string currentPath, string newSavePath)
192192
}
193193

194194
// NOTE: This name is now outdated since we don't have a way to distinguish one workspace
195-
// from another for the extension API.
195+
// from another for the extension API. TODO: Should this be an empty string if we have no
196+
// workspaces?
196197
public string GetWorkspacePath() => _workspaceService.InitialWorkingDirectory;
197198

198199
public string[] GetWorkspacePaths() => _workspaceService.WorkspacePaths.ToArray();

src/PowerShellEditorServices/Services/Workspace/WorkspaceService.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,7 @@ public WorkspaceService(ILoggerFactory factory)
104104

105105
#region Public Methods
106106

107-
public IEnumerable<string> WorkspacePaths => WorkspaceFolders.Count == 0
108-
? new List<string> { InitialWorkingDirectory }
109-
: WorkspaceFolders.Select(i => i.Uri.GetFileSystemPath());
107+
public IEnumerable<string> WorkspacePaths => WorkspaceFolders.Select(i => i.Uri.GetFileSystemPath());
110108

111109
/// <summary>
112110
/// Gets an open file in the workspace. If the file isn't open but exists on the filesystem, load and return it.

0 commit comments

Comments
 (0)