Skip to content

Commit 8e237c3

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 7d547a3 commit 8e237c3

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

Diff for: 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

Diff for: test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,18 @@ public void CanRecurseDirectoryTree()
100100
// suggest it should be find the '.ps1xml' files because we search for the pattern '*.ps1'
101101
// 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_
102102
Assert.Equal(4, fileList.Count);
103-
Assert.Equal(Path.Combine(workspace.WorkspacePath,"nested", "donotfind.ps1"), fileList[0]);
104-
Assert.Equal(Path.Combine(workspace.WorkspacePath,"nested", "nestedmodule.psd1"), fileList[1]);
105-
Assert.Equal(Path.Combine(workspace.WorkspacePath,"nested", "nestedmodule.psm1"), fileList[2]);
103+
Assert.Equal(Path.Combine(workspace.WorkspacePath,"nested") + "/donotfind.ps1", fileList[0]);
104+
Assert.Equal(Path.Combine(workspace.WorkspacePath,"nested") + "/nestedmodule.psd1", fileList[1]);
105+
Assert.Equal(Path.Combine(workspace.WorkspacePath,"nested") + "/nestedmodule.psm1", fileList[2]);
106106
Assert.Equal(Path.Combine(workspace.WorkspacePath,"rootfile.ps1"), fileList[3]);
107107
}
108108
else
109109
{
110110
Assert.Equal(5, fileList.Count);
111-
Assert.Equal(Path.Combine(workspace.WorkspacePath,"nested", "donotfind.ps1"), fileList[0]);
112-
Assert.Equal(Path.Combine(workspace.WorkspacePath,"nested", "nestedmodule.psd1"), fileList[1]);
113-
Assert.Equal(Path.Combine(workspace.WorkspacePath,"nested", "nestedmodule.psm1"), fileList[2]);
114-
Assert.Equal(Path.Combine(workspace.WorkspacePath,"other", "other.ps1xml"), fileList[3]);
111+
Assert.Equal(Path.Combine(workspace.WorkspacePath,"nested") + "/donotfind.ps1", fileList[0]);
112+
Assert.Equal(Path.Combine(workspace.WorkspacePath,"nested") + "/nestedmodule.psd1", fileList[1]);
113+
Assert.Equal(Path.Combine(workspace.WorkspacePath,"nested") + "/nestedmodule.psm1", fileList[2]);
114+
Assert.Equal(Path.Combine(workspace.WorkspacePath,"other") + "/other.ps1xml", fileList[3]);
115115
Assert.Equal(Path.Combine(workspace.WorkspacePath,"rootfile.ps1"), fileList[4]);
116116
}
117117
}
@@ -147,7 +147,7 @@ public void CanRecurseDirectoryTreeWithGlobs()
147147
);
148148

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

0 commit comments

Comments
 (0)