-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,16 +34,16 @@ protected override ValueTask<ImmutableArray<IDiagnosticSource>> GetOrderedDiagno | |
// | ||
// Only consider open documents here (and only closed ones in the WorkspacePullDiagnosticHandler). Each | ||
// handler treats those as separate worlds that they are responsible for. | ||
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([]); | ||
} | ||
|
||
if (!context.IsTracking(textDocument.GetURI())) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
if (!context.IsTracking(identifier.DocumentUri)) | ||
{ | ||
context.TraceWarning($"Ignoring diagnostics request for untracked document: {textDocument.GetURI()}"); | ||
context.TraceWarning($"Ignoring diagnostics request for untracked document: {identifier.DocumentUri}"); | ||
return new([]); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,12 +24,7 @@ internal abstract class AbstractDocumentSyntaxAndSemanticDiagnosticSourceProvide | |
|
||
public ValueTask<ImmutableArray<IDiagnosticSource>> CreateDiagnosticSourcesAsync(RequestContext context, CancellationToken cancellationToken) | ||
{ | ||
if (context.GetTrackedDocument<TextDocument>() is { } document) | ||
{ | ||
return new([new DocumentDiagnosticSource(kind, document)]); | ||
} | ||
|
||
return new([]); | ||
return new([new DocumentDiagnosticSource(kind, context.GetRequiredDocument())]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
} | ||
|
||
[Export(typeof(IDiagnosticSourceProvider)), Shared] | ||
|
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.