File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Sources/SourceKitLSP/Swift Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -1053,7 +1053,20 @@ extension SwiftLanguageServer {
1053
1053
}
1054
1054
1055
1055
public func documentDiagnostic( _ req: DocumentDiagnosticsRequest ) async throws -> DocumentDiagnosticReport {
1056
- return try await . full( fullDocumentDiagnosticReport ( req) )
1056
+ do {
1057
+ return try await . full( fullDocumentDiagnosticReport ( req) )
1058
+ } catch {
1059
+ // VS Code does not request diagnostics again for a document if the diagnostics request failed.
1060
+ // Since sourcekit-lsp usually recovers from failures (e.g. after sourcekitd crashes), this is undesirable.
1061
+ // Instead of returning an error, return empty results.
1062
+ logger. error (
1063
+ """
1064
+ Loading diagnostic failed with the following error. Returning empty diagnostics.
1065
+ \( error. forLogging)
1066
+ """
1067
+ )
1068
+ return . full( RelatedFullDocumentDiagnosticReport ( items: [ ] ) )
1069
+ }
1057
1070
}
1058
1071
1059
1072
private func fullDocumentDiagnosticReport(
You can’t perform that action at this time.
0 commit comments