-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Fix document diagnostics document open check #79298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
c59fb07
to
f6d4d97
Compare
b79547c
to
5f1e719
Compare
5f1e719
to
805447c
Compare
{ | ||
context.TraceDebug("Ignoring diagnostics request because no text document was provided"); | ||
return new([]); | ||
} | ||
|
||
if (!context.IsTracking(textDocument.GetURI())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was the issue - for non-unc paths it does a case sensitive comparison, so the URI created from the file path on disk did not match the opened URI (vscode normalizes it).
instead we use the request uri which per the LSP spec must be consistent with the open URI
} | ||
|
||
return new([]); | ||
return new([new DocumentDiagnosticSource(kind, context.GetRequiredDocument())]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the AbstractDocumentPullDiagnosticHandler.cs code above already verifies that the document is tracked. No need to do it again.
var textDocument = context.TextDocument; | ||
if (textDocument is null) | ||
var identifier = GetTextDocumentIdentifier(diagnosticsParams); | ||
if (identifier is null || context.Document is null) | ||
{ | ||
context.TraceDebug("Ignoring diagnostics request because no text document was provided"); | ||
return new([]); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider breaking this into two checks for better tra ing.
Resolves dotnet/vscode-csharp#8400
VSCode normalizes URIs and always uses the URI based on when the file was first opened (even if it is renamed to change casing). See microsoft/vscode-languageserver-node#1186. So VSCode sends the server a URI that may not match the casing of file on disk.
While we already ignore casing when looking up file paths in the workspace (and therefore find the correct document in the workspace for requests), we had an issue with diagnostics when checking if the file was open. We were comparing a URI created from the file with the URI VSCode sends us. With UNC URIs (windows file paths), case sensitivity is ignored when comparing paths, and so it doesn't matter. However with unix file paths, case sensitivity is not ignored and so the file path URI and VSCode open URI did not match.
The fix here is to instead use the request URI we were given to check if the document is open, instead of attempting to derive it from the file path.