Skip to content

Commit 82e3cbe

Browse files
Ensure tooling tests set up target path correctly
1 parent 81e791f commit 82e3cbe

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/TestRazorProjectService.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Microsoft.CodeAnalysis.Razor.Logging;
1010
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
1111
using Microsoft.CodeAnalysis.Razor.Serialization;
12+
using Microsoft.CodeAnalysis.Razor.Utilities;
1213
using Moq;
1314

1415
namespace Microsoft.AspNetCore.Razor.LanguageServer.ProjectSystem;
@@ -37,13 +38,19 @@ private static IRazorProjectInfoDriver CreateProjectInfoDriver()
3738
return mock.Object;
3839
}
3940

40-
public async Task AddDocumentToPotentialProjectsAsync(string textDocumentPath, CancellationToken cancellationToken)
41+
public async Task AddDocumentToPotentialProjectsAsync(string filePath, CancellationToken cancellationToken)
4142
{
42-
var document = new DocumentSnapshotHandle(
43-
textDocumentPath, textDocumentPath, FileKinds.GetFileKindFromFilePath(textDocumentPath));
44-
45-
foreach (var projectSnapshot in _projectManager.FindPotentialProjects(textDocumentPath))
43+
foreach (var projectSnapshot in _projectManager.FindPotentialProjects(filePath))
4644
{
45+
var projectDirectory = FilePathNormalizer.GetNormalizedDirectoryName(projectSnapshot.FilePath);
46+
var normalizedFilePath = FilePathNormalizer.Normalize(filePath);
47+
48+
var targetPath = normalizedFilePath.StartsWith(projectDirectory)
49+
? normalizedFilePath[projectDirectory.Length..]
50+
: normalizedFilePath;
51+
52+
var document = new DocumentSnapshotHandle(filePath, targetPath, FileKinds.GetFileKindFromFilePath(filePath));
53+
4754
var projectInfo = projectSnapshot.ToRazorProjectInfo();
4855

4956
projectInfo = projectInfo with

0 commit comments

Comments
 (0)