Skip to content

Commit

Permalink
Allow WorkspacePaths to be empty if we're not in a workspace
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
andyleejordan committed Nov 8, 2023
1 parent a691981 commit 8243085
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ public async Task SaveFileAsync(string currentPath, string newSavePath)
}

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

public string[] GetWorkspacePaths() => _workspaceService.WorkspacePaths.ToArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ public WorkspaceService(ILoggerFactory factory)

#region Public Methods

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

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

0 comments on commit 8243085

Please sign in to comment.