[LanguageServerHost] InvalidOperationException: `The solution does not contain the specified document.` after renaming file in Visual Studio Code
- Dominant language
- C#
- Stars
- 20.7k
- Forks
- 4.3k
- PR merge metrics
- PR metrics pending
Description
### Version Used
Compiler: 4.12.0-1.24359.11 (7e282662)
.NET: 9.0.100-preview.6.24328.19
Visual Studio Code: 1.91.1, `f1e16e1e6214d7c44d078b1f0607b2388f29d729`, x64
C# Extension: v2.39.29
C# Dev Kit Extension: v1.9.8
### Steps to Reproduce
1. Create or open a C# project in Visual Studio Code.
2. Fully open any file containing a type symbol.
3. Rename the file from the explorer view (have not tested solution explorer).
4. Wait for the file to be refreshed by the language server.
5. Attempt to navigate to any symbol contained in the file (by default, `Ctrl + Left Click`).
### Expected Behavior
No error is reported.
### Actual Behavior
```
[Error - 4:53:01 PM] [LanguageServerHost] System.InvalidOperationException: The solution does not contain the specified document.
at Microsoft.CodeAnalysis.Shared.Extensions.ISolutionExtensions.GetRequiredDocumentAsync(Solution solution, DocumentId documentId, Boolean includeSourceGenerated, CancellationToken cancellationToken) in /_/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/ISolutionExtensions.cs:line 67
at Microsoft.CodeAnalysis.LanguageServer.Handler.AbstractGoToDefinitionHandler.GetDefinitionsAsync(IGlobalOptionService globalOptions, IMetadataAsSourceFileService metadataAsSourceFileService, Workspace workspace, Document document, Boolean typeOnly, LinePosition linePosition, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Handler/Definitions/AbstractGoToDefinitionHandler.cs:line 67
at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.StartRequestAsync[TRequest,TResponse](TRequest request, TRequestContext context, IMethodHandler handler, String language, CancellationToken cancellationToken)
[Error - 4:53:01 PM] Request textDocument/definition failed.
Message: The solution does not contain the specified document.
Code: -32000
```
Contributor guide
Assessment
This issue has not been assessed yet.