Skip to content

Commit 0442cab

Browse files
committed
Comments
1 parent f1846a1 commit 0442cab

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/RazorProjectService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ public Task OpenDocumentAsync(string filePath, SourceText sourceText, int versio
9393
if (!_snapshotResolver.TryResolveDocumentInAnyProject(textDocumentPath, out var document))
9494
{
9595
// Document hasn't been added. This usually occurs when VSCode trumps all other initialization
96-
// processes and pre-initializes already open documents.
96+
// processes and pre-initializes already open documents. We add this to the misc project, and
97+
// if/when we get project info from the client, it will be migrated to a real project.
9798
AddDocumentToMiscProjectCore(updater, filePath);
9899
}
99100

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorFileSynchronizer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ internal class RazorFileSynchronizer(IRazorProjectService projectService) : IRaz
1717
public Task RazorFileChangedAsync(string filePath, RazorFileChangeKind kind, CancellationToken cancellationToken)
1818
=> kind switch
1919
{
20+
// We put the new file in the misc files project, so we don't confuse the client by sending updates for
21+
// a razor file that we guess is going to be in a project, when the client might not have received that
22+
// info yet. When the client does find out, it will tell us by updating the project info, and we'll
23+
// migrate the file as necessary.
2024
RazorFileChangeKind.Added => _projectService.AddDocumentToMiscProjectAsync(filePath, cancellationToken),
2125
RazorFileChangeKind.Removed => _projectService.RemoveDocumentAsync(filePath, cancellationToken),
2226
_ => Task.CompletedTask

0 commit comments

Comments
 (0)