File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed
Sources/SourceKitLSP/Swift Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -888,12 +888,15 @@ extension SwiftLanguageService {
888888 buildSettings: buildSettings
889889 )
890890 return . full( diagnosticReport)
891- } catch let error as CancellationError {
892- throw error
893891 } catch {
894892 // VS Code does not request diagnostics again for a document if the diagnostics request failed.
895893 // Since sourcekit-lsp usually recovers from failures (e.g. after sourcekitd crashes), this is undesirable.
896894 // Instead of returning an error, return empty results.
895+ // Do forward cancellation because we don't want to clear diagnostics in the client if they cancel the diagnostic
896+ // request.
897+ if ResponseError ( error) == . cancelled {
898+ throw error
899+ }
897900 logger. error (
898901 """
899902 Loading diagnostic failed with the following error. Returning empty diagnostics.
Original file line number Diff line number Diff line change @@ -337,7 +337,7 @@ final class PullDiagnosticsTests: XCTestCase {
337337 let requestID = project. testClient. send (
338338 DocumentDiagnosticsRequest ( textDocument: TextDocumentIdentifier ( uri) )
339339 ) { result in
340- XCTAssertEqual ( result. failure ? . code , . cancelled)
340+ XCTAssertEqual ( result, . failure ( ResponseError . cancelled) )
341341 diagnosticResponseReceived. fulfill ( )
342342 }
343343 project. testClient. send ( CancelRequestNotification ( id: requestID) )
You can’t perform that action at this time.
0 commit comments