-
Notifications
You must be signed in to change notification settings - Fork 234
WIP: Support multi-root workspace #1992
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
Conversation
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); | ||
} |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
if (workspaceUri.IsBaseOf(fileUri)) | ||
{ | ||
resolvedPath = workspaceUri.MakeRelativeUri(fileUri).ToString(); | ||
break; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this works 😅
// NOTE: We're still maintaining a root path while things transition to | ||
// support multi-root workspaces. | ||
workspaceService.WorkspacePath = hostStartOptions.InitialWorkingDirectory; | ||
|
There was a problem hiding this comment.
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.
/// TODO: This API needs to be deprecated for new `Paths` instead. | ||
/// </summary> | ||
public string Path => editorOperations.GetWorkspacePath(); |
There was a problem hiding this comment.
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 💁
Whacha think @SeeminglyScience? |
34d81b3
to
ceaa90b
Compare
ceaa90b
to
3d10a3a
Compare
Closing in favor of #2053. |
This time in the server. Resolves PowerShell/vscode-powershell#2112 but needs tests and some more work.