about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-08-13 18:35:09 +0000
committerbors <bors@rust-lang.org>2022-08-13 18:35:09 +0000
commitbbe5637bbf0f6dcdc62062f7d50a3947026be9f9 (patch)
tree17d6721e2ed6bafc340eac2970f9813c09fb2b4b
parent306687b640e0453e4a95de5eae8933f65c9e3757 (diff)
parentec8256dd8027bbe5493698e4b9125f1f0cf8c646 (diff)
downloadrust-bbe5637bbf0f6dcdc62062f7d50a3947026be9f9.tar.gz
rust-bbe5637bbf0f6dcdc62062f7d50a3947026be9f9.zip
Auto merge of #13016 - Veykril:vscode-diag-workaround, r=Veykril
Move VSCode diagnostics workaroudn into client code
-rw-r--r--crates/rust-analyzer/src/handlers.rs3
-rw-r--r--crates/rust-analyzer/src/main_loop.rs22
-rw-r--r--editors/code/src/client.ts9
3 files changed, 14 insertions, 20 deletions
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index 47daa732d5d..943d043bc19 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -1320,8 +1320,7 @@ pub(crate) fn publish_diagnostics(
                 .unwrap(),
             }),
             source: Some("rust-analyzer".to_string()),
-            // https://github.com/rust-lang/rust-analyzer/issues/11404
-            message: if !d.message.is_empty() { d.message } else { " ".to_string() },
+            message: d.message,
             related_information: None,
             tags: if d.unused { Some(vec![DiagnosticTag::UNNECESSARY]) } else { None },
             data: None,
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 92b6be22e76..77419998249 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -327,29 +327,15 @@ impl GlobalState {
                     continue;
                 }
 
-                let url = file_id_to_url(&self.vfs.read().0, file_id);
-                let mut diagnostics =
+                let uri = file_id_to_url(&self.vfs.read().0, file_id);
+                let diagnostics =
                     self.diagnostics.diagnostics_for(file_id).cloned().collect::<Vec<_>>();
-                for d in &mut diagnostics {
-                    // https://github.com/rust-lang/rust-analyzer/issues/11404
-                    // FIXME: We should move this workaround into the client code
-                    if d.message.is_empty() {
-                        d.message = " ".to_string();
-                    }
-                    if let Some(rds) = d.related_information.as_mut() {
-                        for rd in rds {
-                            if rd.message.is_empty() {
-                                rd.message = " ".to_string();
-                            }
-                        }
-                    }
-                }
-                let version = from_proto::vfs_path(&url)
+                let version = from_proto::vfs_path(&uri)
                     .map(|path| self.mem_docs.get(&path).map(|it| it.version))
                     .unwrap_or_default();
 
                 self.send_notification::<lsp_types::notification::PublishDiagnostics>(
-                    lsp_types::PublishDiagnosticsParams { uri: url, diagnostics, version },
+                    lsp_types::PublishDiagnosticsParams { uri, diagnostics, version },
                 );
             }
         }
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts
index 8a2dea6b35b..40ba17844be 100644
--- a/editors/code/src/client.ts
+++ b/editors/code/src/client.ts
@@ -105,6 +105,15 @@ export async function createClient(
         traceOutputChannel: traceOutputChannel(),
         outputChannel: outputChannel(),
         middleware: {
+            async handleDiagnostics(uri, diagnostics, next) {
+                // Workaround for https://github.com/microsoft/vscode/issues/155531
+                for (const diagnostic of diagnostics) {
+                    if (!diagnostic.message) {
+                        diagnostic.message = " ";
+                    }
+                }
+                next(uri, diagnostics);
+            },
             async provideHover(
                 document: vscode.TextDocument,
                 position: vscode.Position,