|
1 | | -use lsp_server::ErrorCode; |
2 | 1 | use lsp_types::notification::PublishDiagnostics; |
3 | 2 | use lsp_types::{ |
4 | 3 | CodeDescription, Diagnostic, DiagnosticRelatedInformation, DiagnosticSeverity, DiagnosticTag, |
@@ -46,20 +45,17 @@ impl Diagnostics { |
46 | 45 | /// This is done by notifying the client with an empty list of diagnostics for the document. |
47 | 46 | /// For notebook cells, this clears diagnostics for the specific cell. |
48 | 47 | /// For other document types, this clears diagnostics for the main document. |
49 | | -pub(super) fn clear_diagnostics(key: &DocumentKey, client: &Client) -> Result<()> { |
| 48 | +pub(super) fn clear_diagnostics(key: &DocumentKey, client: &Client) { |
50 | 49 | let Some(uri) = key.to_url() else { |
51 | 50 | // If we can't convert to URL, we can't clear diagnostics |
52 | | - return Ok(()); |
| 51 | + return; |
53 | 52 | }; |
54 | 53 |
|
55 | | - client |
56 | | - .send_notification::<PublishDiagnostics>(PublishDiagnosticsParams { |
57 | | - uri, |
58 | | - diagnostics: vec![], |
59 | | - version: None, |
60 | | - }) |
61 | | - .with_failure_code(ErrorCode::InternalError)?; |
62 | | - Ok(()) |
| 54 | + client.send_notification::<PublishDiagnostics>(PublishDiagnosticsParams { |
| 55 | + uri, |
| 56 | + diagnostics: vec![], |
| 57 | + version: None, |
| 58 | + }); |
63 | 59 | } |
64 | 60 |
|
65 | 61 | /// Publishes the diagnostics for the given document snapshot using the [publish diagnostics |
@@ -96,22 +92,20 @@ pub(super) fn publish_diagnostics( |
96 | 92 |
|
97 | 93 | // Sends a notification to the client with the diagnostics for the document. |
98 | 94 | let publish_diagnostics_notification = |uri: Url, diagnostics: Vec<Diagnostic>| { |
99 | | - client |
100 | | - .send_notification::<PublishDiagnostics>(PublishDiagnosticsParams { |
101 | | - uri, |
102 | | - diagnostics, |
103 | | - version: Some(snapshot.query().version()), |
104 | | - }) |
105 | | - .with_failure_code(lsp_server::ErrorCode::InternalError) |
| 95 | + client.send_notification::<PublishDiagnostics>(PublishDiagnosticsParams { |
| 96 | + uri, |
| 97 | + diagnostics, |
| 98 | + version: Some(snapshot.query().version()), |
| 99 | + }); |
106 | 100 | }; |
107 | 101 |
|
108 | 102 | match diagnostics { |
109 | 103 | Diagnostics::TextDocument(diagnostics) => { |
110 | | - publish_diagnostics_notification(url, diagnostics)?; |
| 104 | + publish_diagnostics_notification(url, diagnostics); |
111 | 105 | } |
112 | 106 | Diagnostics::NotebookDocument(cell_diagnostics) => { |
113 | 107 | for (cell_url, diagnostics) in cell_diagnostics { |
114 | | - publish_diagnostics_notification(cell_url, diagnostics)?; |
| 108 | + publish_diagnostics_notification(cell_url, diagnostics); |
115 | 109 | } |
116 | 110 | } |
117 | 111 | } |
|
0 commit comments