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:
Conrad Irwin 2025-04-29 19:53:05 -06:00 committed by GitHub
parent b4732235e3
commit e364e48266
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 106 additions and 99 deletions

View file

@ -283,6 +283,12 @@ impl LspAdapter for RustLspAdapter {
}
}
fn diagnostic_message_to_markdown(&self, message: &str) -> Option<String> {
static REGEX: LazyLock<Regex> =
LazyLock::new(|| Regex::new(r"(?m)\n *").expect("Failed to create REGEX"));
Some(REGEX.replace_all(message, "\n\n").to_string())
}
async fn label_for_completion(
&self,
completion: &lsp::CompletionItem,