mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-29 14:33:29 +00:00
Move VSCode diagnostics workaroudn into client code
This commit is contained in:
parent
038c36a1f5
commit
ec8256dd80
3 changed files with 14 additions and 20 deletions
|
@ -1320,8 +1320,7 @@ pub(crate) fn publish_diagnostics(
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
}),
|
}),
|
||||||
source: Some("rust-analyzer".to_string()),
|
source: Some("rust-analyzer".to_string()),
|
||||||
// https://github.com/rust-lang/rust-analyzer/issues/11404
|
message: d.message,
|
||||||
message: if !d.message.is_empty() { d.message } else { " ".to_string() },
|
|
||||||
related_information: None,
|
related_information: None,
|
||||||
tags: if d.unused { Some(vec![DiagnosticTag::UNNECESSARY]) } else { None },
|
tags: if d.unused { Some(vec![DiagnosticTag::UNNECESSARY]) } else { None },
|
||||||
data: None,
|
data: None,
|
||||||
|
|
|
@ -327,29 +327,15 @@ impl GlobalState {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let url = file_id_to_url(&self.vfs.read().0, file_id);
|
let uri = file_id_to_url(&self.vfs.read().0, file_id);
|
||||||
let mut diagnostics =
|
let diagnostics =
|
||||||
self.diagnostics.diagnostics_for(file_id).cloned().collect::<Vec<_>>();
|
self.diagnostics.diagnostics_for(file_id).cloned().collect::<Vec<_>>();
|
||||||
for d in &mut diagnostics {
|
let version = from_proto::vfs_path(&uri)
|
||||||
// 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)
|
|
||||||
.map(|path| self.mem_docs.get(&path).map(|it| it.version))
|
.map(|path| self.mem_docs.get(&path).map(|it| it.version))
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
self.send_notification::<lsp_types::notification::PublishDiagnostics>(
|
self.send_notification::<lsp_types::notification::PublishDiagnostics>(
|
||||||
lsp_types::PublishDiagnosticsParams { uri: url, diagnostics, version },
|
lsp_types::PublishDiagnosticsParams { uri, diagnostics, version },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,6 +105,15 @@ export async function createClient(
|
||||||
traceOutputChannel: traceOutputChannel(),
|
traceOutputChannel: traceOutputChannel(),
|
||||||
outputChannel: outputChannel(),
|
outputChannel: outputChannel(),
|
||||||
middleware: {
|
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(
|
async provideHover(
|
||||||
document: vscode.TextDocument,
|
document: vscode.TextDocument,
|
||||||
position: vscode.Position,
|
position: vscode.Position,
|
||||||
|
|
Loading…
Reference in a new issue