Tidy up diagnostics more (#29629)
- Stop merging same row diagnostics - (for Rust) show code fragments surrounded by `'s in monospace Co-authored-by: Serge Radinovich <sergeradinovich@gmail.com> Closes #29362 Release Notes: - diagnostics: Diagnostics are no longer merged when they're on the same line - rust: Diagnostics now show code snippets in monospace font: <img width="551" alt="Screenshot 2025-04-29 at 16 13 45" src="https://github.com/user-attachments/assets/d289be31-717d-404f-a76a-a0cda3e96fbe" /> Co-authored-by: Serge Radinovich <sergeradinovich@gmail.com>
This commit is contained in:
parent
b4732235e3
commit
e364e48266
9 changed files with 106 additions and 99 deletions
|
@ -213,6 +213,8 @@ pub struct Diagnostic {
|
|||
pub severity: DiagnosticSeverity,
|
||||
/// The human-readable message associated with this diagnostic.
|
||||
pub message: String,
|
||||
/// The human-readable message (in markdown format)
|
||||
pub markdown: Option<String>,
|
||||
/// An id that identifies the group to which this diagnostic belongs.
|
||||
///
|
||||
/// When a language server produces a diagnostic with
|
||||
|
@ -4616,6 +4618,7 @@ impl Default for Diagnostic {
|
|||
code_description: None,
|
||||
severity: DiagnosticSeverity::ERROR,
|
||||
message: Default::default(),
|
||||
markdown: None,
|
||||
group_id: 0,
|
||||
is_primary: false,
|
||||
is_disk_based: false,
|
||||
|
|
|
@ -239,6 +239,10 @@ impl CachedLspAdapter {
|
|||
.process_diagnostics(params, server_id, existing_diagnostics)
|
||||
}
|
||||
|
||||
pub fn diagnostic_message_to_markdown(&self, message: &str) -> Option<String> {
|
||||
self.adapter.diagnostic_message_to_markdown(message)
|
||||
}
|
||||
|
||||
pub async fn process_completions(&self, completion_items: &mut [lsp::CompletionItem]) {
|
||||
self.adapter.process_completions(completion_items).await
|
||||
}
|
||||
|
@ -460,6 +464,10 @@ pub trait LspAdapter: 'static + Send + Sync {
|
|||
/// Post-processes completions provided by the language server.
|
||||
async fn process_completions(&self, _: &mut [lsp::CompletionItem]) {}
|
||||
|
||||
fn diagnostic_message_to_markdown(&self, _message: &str) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
async fn labels_for_completions(
|
||||
self: Arc<Self>,
|
||||
completions: &[lsp::CompletionItem],
|
||||
|
|
|
@ -203,6 +203,7 @@ pub fn serialize_diagnostics<'a>(
|
|||
start: Some(serialize_anchor(&entry.range.start)),
|
||||
end: Some(serialize_anchor(&entry.range.end)),
|
||||
message: entry.diagnostic.message.clone(),
|
||||
markdown: entry.diagnostic.markdown.clone(),
|
||||
severity: match entry.diagnostic.severity {
|
||||
DiagnosticSeverity::ERROR => proto::diagnostic::Severity::Error,
|
||||
DiagnosticSeverity::WARNING => proto::diagnostic::Severity::Warning,
|
||||
|
@ -422,6 +423,7 @@ pub fn deserialize_diagnostics(
|
|||
proto::diagnostic::Severity::None => return None,
|
||||
},
|
||||
message: diagnostic.message,
|
||||
markdown: diagnostic.markdown,
|
||||
group_id: diagnostic.group_id as usize,
|
||||
code: diagnostic.code.map(lsp::NumberOrString::from_string),
|
||||
code_description: diagnostic
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue