Skip to content

Commit 19b2703

Browse files
committed
(GH-879) Do not normalise paths from EnumeratePSFiles
Previously the paths emitted by `EnumeratePSFiles` were normalised to use the directory path separator appropriate for the platform. In particular on Windows the paths emitted by the Microsoft.Extensions.FileSystemGlobbing library contained both forward and backward slashes. However on inspection this is not required as all the paths are converted to URIs when communicating over LSP, so the normalisation is no longer required. This commit removes the normalisation and updates the tests to reflect the new paths.
1 parent ed33575 commit 19b2703

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/PowerShellEditorServices/Workspace/Workspace.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ bool ignoreReparsePoints
357357
var fileMatchResult = matcher.Execute(fsFactory.RootDirectory);
358358
foreach (FilePatternMatch item in fileMatchResult.Files)
359359
{
360-
yield return Path.Combine(WorkspacePath, item.Path.Replace('/', Path.DirectorySeparatorChar));
360+
yield return Path.Combine(WorkspacePath, item.Path);
361361
}
362362
}
363363

test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,18 @@ public void CanRecurseDirectoryTree()
102102
// suggest it should be find the '.ps1xml' files because we search for the pattern '*.ps1'
103103
// ref https://docs.microsoft.com/en-us/dotnet/api/system.io.directory.getfiles?view=netcore-2.1#System_IO_Directory_GetFiles_System_String_System_String_System_IO_EnumerationOptions_
104104
Assert.Equal(4, fileList.Count);
105-
Assert.Equal(Path.Combine(workspace.WorkspacePath,"nested", "donotfind.ps1"), fileList[0]);
106-
Assert.Equal(Path.Combine(workspace.WorkspacePath,"nested", "nestedmodule.psd1"), fileList[1]);
107-
Assert.Equal(Path.Combine(workspace.WorkspacePath,"nested", "nestedmodule.psm1"), fileList[2]);
105+
Assert.Equal(Path.Combine(workspace.WorkspacePath,"nested") + "/donotfind.ps1", fileList[0]);
106+
Assert.Equal(Path.Combine(workspace.WorkspacePath,"nested") + "/nestedmodule.psd1", fileList[1]);
107+
Assert.Equal(Path.Combine(workspace.WorkspacePath,"nested") + "/nestedmodule.psm1", fileList[2]);
108108
Assert.Equal(Path.Combine(workspace.WorkspacePath,"rootfile.ps1"), fileList[3]);
109109
}
110110
else
111111
{
112112
Assert.Equal(5, fileList.Count);
113-
Assert.Equal(Path.Combine(workspace.WorkspacePath,"nested", "donotfind.ps1"), fileList[0]);
114-
Assert.Equal(Path.Combine(workspace.WorkspacePath,"nested", "nestedmodule.psd1"), fileList[1]);
115-
Assert.Equal(Path.Combine(workspace.WorkspacePath,"nested", "nestedmodule.psm1"), fileList[2]);
116-
Assert.Equal(Path.Combine(workspace.WorkspacePath,"other", "other.ps1xml"), fileList[3]);
113+
Assert.Equal(Path.Combine(workspace.WorkspacePath,"nested") + "/donotfind.ps1", fileList[0]);
114+
Assert.Equal(Path.Combine(workspace.WorkspacePath,"nested") + "/nestedmodule.psd1", fileList[1]);
115+
Assert.Equal(Path.Combine(workspace.WorkspacePath,"nested") + "/nestedmodule.psm1", fileList[2]);
116+
Assert.Equal(Path.Combine(workspace.WorkspacePath,"other") + "/other.ps1xml", fileList[3]);
117117
Assert.Equal(Path.Combine(workspace.WorkspacePath,"rootfile.ps1"), fileList[4]);
118118
}
119119
}
@@ -149,7 +149,7 @@ public void CanRecurseDirectoryTreeWithGlobs()
149149
);
150150

151151
Assert.Equal(2, fileList.Count);
152-
Assert.Equal(Path.Combine(workspace.WorkspacePath,"nested", "nestedmodule.psd1"), fileList[0]);
152+
Assert.Equal(Path.Combine(workspace.WorkspacePath,"nested") + "/nestedmodule.psd1", fileList[0]);
153153
Assert.Equal(Path.Combine(workspace.WorkspacePath,"rootfile.ps1"), fileList[1]);
154154
}
155155

0 commit comments

Comments
 (0)