@@ -180,6 +180,34 @@ void M()
180
180
Assert . Null ( GetMiscellaneousDocument ( testLspServer ) ) ;
181
181
}
182
182
183
+ [ Theory , CombinatorialData ]
184
+ public async Task TestLooseFile_RazorFile ( bool mutatingLspWorkspace )
185
+ {
186
+ var source = "<div></div>" ;
187
+
188
+ // Create a server that supports LSP misc files and verify no misc files present.
189
+ await using var testLspServer = await CreateTestLspServerAsync ( string . Empty , mutatingLspWorkspace , new InitializationOptions { ServerKind = WellKnownLspServerKinds . CSharpVisualBasicLspServer } ) ;
190
+ Assert . Null ( GetMiscellaneousDocument ( testLspServer ) ) ;
191
+ Assert . Null ( GetMiscellaneousAdditionalDocument ( testLspServer ) ) ;
192
+
193
+ // Open an empty loose file and make a request to verify it gets added to the misc workspace.
194
+ var looseFileUri = ProtocolConversions . CreateAbsoluteUri ( @"C:\SomeFile.razor" ) ;
195
+ await testLspServer . OpenDocumentAsync ( looseFileUri , source ) . ConfigureAwait ( false ) ;
196
+
197
+ // Trigger a request and assert we got a file in the misc workspace.
198
+ await AssertFileInMiscWorkspaceAsync ( testLspServer , looseFileUri ) . ConfigureAwait ( false ) ;
199
+ Assert . Null ( GetMiscellaneousDocument ( testLspServer ) ) ;
200
+ Assert . NotNull ( GetMiscellaneousAdditionalDocument ( testLspServer ) ) ;
201
+
202
+ // Trigger another request and assert we got a file in the misc workspace.
203
+ await AssertFileInMiscWorkspaceAsync ( testLspServer , looseFileUri ) . ConfigureAwait ( false ) ;
204
+ Assert . NotNull ( GetMiscellaneousAdditionalDocument ( testLspServer ) ) ;
205
+
206
+ await testLspServer . CloseDocumentAsync ( looseFileUri ) . ConfigureAwait ( false ) ;
207
+ Assert . Null ( GetMiscellaneousDocument ( testLspServer ) ) ;
208
+ Assert . Null ( GetMiscellaneousAdditionalDocument ( testLspServer ) ) ;
209
+ }
210
+
183
211
[ Theory , CombinatorialData ]
184
212
public async Task TestLooseFile_RequestedTwiceAndClosed ( bool mutatingLspWorkspace )
185
213
{
@@ -306,7 +334,12 @@ private static async Task AssertFileInMainWorkspaceAsync(TestLspServer testLspSe
306
334
307
335
private static Document ? GetMiscellaneousDocument ( TestLspServer testLspServer )
308
336
{
309
- return testLspServer . GetManagerAccessor ( ) . GetLspMiscellaneousFilesWorkspace ( ) ! . CurrentSolution . Projects . SingleOrDefault ( ) ? . Documents . Single ( ) ;
337
+ return testLspServer . GetManagerAccessor ( ) . GetLspMiscellaneousFilesWorkspace ( ) ! . CurrentSolution . Projects . SingleOrDefault ( ) ? . Documents . SingleOrDefault ( ) ;
338
+ }
339
+
340
+ private static TextDocument ? GetMiscellaneousAdditionalDocument ( TestLspServer testLspServer )
341
+ {
342
+ return testLspServer . GetManagerAccessor ( ) . GetLspMiscellaneousFilesWorkspace ( ) ! . CurrentSolution . Projects . SingleOrDefault ( ) ? . AdditionalDocuments . SingleOrDefault ( ) ;
310
343
}
311
344
312
345
private static async Task < LSP . Hover > RunGetHoverAsync ( TestLspServer testLspServer , LSP . Location caret )
0 commit comments