Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Support multi-root workspace #1992

Closed
wants to merge 1 commit into from

Conversation

andyleejordan
Copy link
Member

This time in the server. Resolves PowerShell/vscode-powershell#2112 but needs tests and some more work.

Comment on lines 365 to 391
foreach (WorkspaceFolder workspaceFolder in WorkspaceFolders)
{
// item.Path always contains forward slashes in paths when it should be backslashes on Windows.
// Since we're returning strings here, it's important to use the correct directory separator.
string path = VersionUtils.IsWindows ? item.Path.Replace('/', Path.DirectorySeparatorChar) : item.Path;
yield return Path.Combine(WorkspacePath, path);
string rootPath = workspaceFolder.Uri.GetFileSystemPath();
if (!Directory.Exists(rootPath))
{
continue;
}

WorkspaceFileSystemWrapperFactory fsFactory = new(
rootPath,
maxDepth,
VersionUtils.IsNetCore ? s_psFileExtensionsCoreFramework : s_psFileExtensionsFullFramework,
ignoreReparsePoints,
logger);

PatternMatchingResult fileMatchResult = matcher.Execute(fsFactory.RootDirectory);
foreach (FilePatternMatch item in fileMatchResult.Files)
{
// item.Path always contains forward slashes in paths when it should be backslashes on Windows.
// Since we're returning strings here, it's important to use the correct directory separator.
string path = VersionUtils.IsWindows ? item.Path.Replace('/', Path.DirectorySeparatorChar) : item.Path;
yield return Path.Combine(rootPath, path);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This worked in my testing of a multi-root workspace, now PowerShell symbols from both (and so presumably all) folders showed up!


if (!IsPathInMemory(filePath) && !string.IsNullOrEmpty(WorkspacePath))
if (!scriptFile.IsInMemory)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think IsPathInMemory can go away because it's only used in two tests now, and IsInMemory is used everywhere else. Not sure why we had two ways to go about that.

Comment on lines +314 to +324
if (workspaceUri.IsBaseOf(fileUri))
{
resolvedPath = workspaceUri.MakeRelativeUri(fileUri).ToString();
break;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this works 😅

Comment on lines 155 to 161
// NOTE: We're still maintaining a root path while things transition to
// support multi-root workspaces.
workspaceService.WorkspacePath = hostStartOptions.InitialWorkingDirectory;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main thing we still use this for is resolving the path to the PSScriptAnalyzer settings file. People give relative paths...but we have no way of asking "ok, but relative to which root?" and so for now the logic is "your initial working directory setting" first (so it can be corrected if necessary) and then fall back to the "first" (but presumably random sorting) workspace folder.

Comment on lines 22 to 23
/// TODO: This API needs to be deprecated for new `Paths` instead.
/// </summary>
public string Path => editorOperations.GetWorkspacePath();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why oh why did we ever write a public API 💁

@andyleejordan
Copy link
Member Author

Whacha think @SeeminglyScience?

@andyleejordan
Copy link
Member Author

Closing in favor of #2053.

@andyleejordan andyleejordan deleted the andschwa/multi-workspace branch August 17, 2023 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

References doesn't work for 2nd project within one workspace
2 participants