@@ -1427,85 +1427,89 @@ fn compute_inlay_hints_for_view(
1427
1427
1428
1428
pub fn pull_diagnostic_for_current_doc ( editor : & Editor , jobs : & mut crate :: job:: Jobs ) {
1429
1429
let doc = doc ! ( editor) ;
1430
- let Some ( language_server) = doc
1431
- . language_servers_with_feature ( LanguageServerFeature :: PullDiagnostics )
1432
- . next ( )
1433
- else {
1434
- return ;
1435
- } ;
1436
1430
1437
- let future = language_server
1438
- . text_document_diagnostic ( doc. identifier ( ) , doc. previous_diagnostic_id . clone ( ) ) ;
1431
+ for language_server in doc. language_servers_with_feature ( LanguageServerFeature :: PullDiagnostics )
1432
+ {
1433
+ let future = language_server
1434
+ . text_document_diagnostic ( doc. identifier ( ) , doc. previous_diagnostic_id . clone ( ) ) ;
1435
+
1436
+ let server_id = language_server. id ( ) ;
1437
+ let original_path = doc
1438
+ . path ( )
1439
+ . expect ( "safety: the file has a path if there is a running language server" )
1440
+ . to_owned ( ) ;
1441
+
1442
+ let callback = super :: make_job_callback (
1443
+ future. expect ( "safety: language server supports pull diagnostics" ) ,
1444
+ move |editor, _compositor, response : Option < lsp:: DocumentDiagnosticReport > | {
1445
+ let parse_diagnostic =
1446
+ |editor : & mut Editor ,
1447
+ path : PathBuf ,
1448
+ report : Vec < lsp:: Diagnostic > ,
1449
+ result_id : Option < String > | {
1450
+ let uri = helix_core:: Uri :: try_from ( path) ;
1451
+ let diagnostics: Vec < ( Diagnostic , LanguageServerId ) > =
1452
+ report. into_iter ( ) . map ( |d| ( d, server_id) ) . collect ( ) ;
1453
+
1454
+ if let Ok ( uri) = uri {
1455
+ editor. add_diagnostics ( diagnostics, server_id, uri, None , result_id) ;
1456
+ }
1457
+ } ;
1439
1458
1440
- let server_id = language_server. id ( ) ;
1441
- let original_path = doc
1442
- . path ( )
1443
- . expect ( "safety: the file has a path if there is a running language server" )
1444
- . to_owned ( ) ;
1459
+ let handle_document_diagnostic_report_kind = |editor : & mut Editor ,
1460
+ report : Option <
1461
+ HashMap < lsp:: Url , lsp:: DocumentDiagnosticReportKind > ,
1462
+ > | {
1463
+ for ( url, report) in report. into_iter ( ) . flatten ( ) {
1464
+ match report {
1465
+ lsp:: DocumentDiagnosticReportKind :: Full ( report) => {
1466
+ let path = url. to_file_path ( ) . unwrap ( ) ;
1467
+ parse_diagnostic ( editor, path, report. items , report. result_id ) ;
1468
+ }
1469
+ lsp:: DocumentDiagnosticReportKind :: Unchanged ( report) => {
1470
+ let Some ( doc) = editor. document_by_path_mut ( url. path ( ) ) else {
1471
+ return ;
1472
+ } ;
1473
+ doc. previous_diagnostic_id = Some ( report. result_id ) ;
1474
+ }
1475
+ }
1476
+ }
1477
+ } ;
1445
1478
1446
- let callback = super :: make_job_callback (
1447
- future. expect ( "safety: language server supports pull diagnostics" ) ,
1448
- move |editor, _compositor, response : Option < lsp:: DocumentDiagnosticReport > | {
1449
- let parse_diagnostic = |editor : & mut Editor ,
1450
- path : PathBuf ,
1451
- report : Vec < lsp:: Diagnostic > ,
1452
- result_id : Option < String > | {
1453
- let uri = helix_core:: Uri :: try_from ( path) ;
1454
- let diagnostics: Vec < ( Diagnostic , LanguageServerId ) > =
1455
- report. into_iter ( ) . map ( |d| ( d, server_id) ) . collect ( ) ;
1456
-
1457
- if let Ok ( uri) = uri {
1458
- editor. add_diagnostics ( diagnostics, server_id, uri, None , result_id) ;
1459
- }
1460
- } ;
1479
+ if let Some ( response) = response {
1480
+ let doc = match editor. document_by_path_mut ( & original_path) {
1481
+ Some ( doc) => doc,
1482
+ None => return ,
1483
+ } ;
1484
+ match response {
1485
+ lsp:: DocumentDiagnosticReport :: Full ( report) => {
1486
+ // Original file diagnostic
1487
+ parse_diagnostic (
1488
+ editor,
1489
+ original_path,
1490
+ report. full_document_diagnostic_report . items ,
1491
+ report. full_document_diagnostic_report . result_id ,
1492
+ ) ;
1461
1493
1462
- let handle_document_diagnostic_report_kind = |editor : & mut Editor ,
1463
- report : Option <
1464
- HashMap < lsp:: Url , lsp:: DocumentDiagnosticReportKind > ,
1465
- > | {
1466
- for ( url, report) in report. into_iter ( ) . flatten ( ) {
1467
- match report {
1468
- lsp:: DocumentDiagnosticReportKind :: Full ( report) => {
1469
- let path = url. to_file_path ( ) . unwrap ( ) ;
1470
- parse_diagnostic ( editor, path, report. items , report. result_id ) ;
1494
+ // Related files diagnostic
1495
+ handle_document_diagnostic_report_kind (
1496
+ editor,
1497
+ report. related_documents ,
1498
+ ) ;
1471
1499
}
1472
- lsp:: DocumentDiagnosticReportKind :: Unchanged ( report) => {
1473
- let Some ( doc) = editor. document_by_path_mut ( url. path ( ) ) else {
1474
- return ;
1475
- } ;
1476
- doc. previous_diagnostic_id = Some ( report. result_id ) ;
1500
+ lsp:: DocumentDiagnosticReport :: Unchanged ( report) => {
1501
+ doc. previous_diagnostic_id =
1502
+ Some ( report. unchanged_document_diagnostic_report . result_id ) ;
1503
+ handle_document_diagnostic_report_kind (
1504
+ editor,
1505
+ report. related_documents ,
1506
+ ) ;
1477
1507
}
1478
1508
}
1479
1509
}
1480
- } ;
1481
-
1482
- if let Some ( response) = response {
1483
- let doc = match editor. document_by_path_mut ( & original_path) {
1484
- Some ( doc) => doc,
1485
- None => return ,
1486
- } ;
1487
- match response {
1488
- lsp:: DocumentDiagnosticReport :: Full ( report) => {
1489
- // Original file diagnostic
1490
- parse_diagnostic (
1491
- editor,
1492
- original_path,
1493
- report. full_document_diagnostic_report . items ,
1494
- report. full_document_diagnostic_report . result_id ,
1495
- ) ;
1496
-
1497
- // Related files diagnostic
1498
- handle_document_diagnostic_report_kind ( editor, report. related_documents ) ;
1499
- }
1500
- lsp:: DocumentDiagnosticReport :: Unchanged ( report) => {
1501
- doc. previous_diagnostic_id =
1502
- Some ( report. unchanged_document_diagnostic_report . result_id ) ;
1503
- handle_document_diagnostic_report_kind ( editor, report. related_documents ) ;
1504
- }
1505
- }
1506
- }
1507
- } ,
1508
- ) ;
1510
+ } ,
1511
+ ) ;
1509
1512
1510
- jobs. callback ( callback) ;
1513
+ jobs. callback ( callback) ;
1514
+ }
1511
1515
}
0 commit comments