Allow LSP adapters to decide, which diagnostics to underline (#31450)

Closes
https://github.com/zed-industries/zed/pull/31355#issuecomment-2910439798

<img width="1728" alt="image"
src="https://github.com/user-attachments/assets/2eaa8e9b-00bc-4e99-ac09-fceb2d932e41"
/>


Release Notes:

- N/A
This commit is contained in:
Kirill Bulatov 2025-05-26 22:19:02 +03:00 committed by GitHub
parent 4c396bcc91
commit 4567360fd9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 53 additions and 5 deletions

View file

@ -960,11 +960,8 @@ impl DisplaySnapshot {
}) {
if chunk.is_unnecessary {
diagnostic_highlight.fade_out = Some(editor_style.unnecessary_code_fade);
// https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#diagnosticTag
// states that
// > Clients are allowed to render diagnostics with this tag faded out instead of having an error squiggle.
// for the unnecessary diagnostics, so do not underline them.
} else if editor_style.show_underlines {
}
if chunk.underline && editor_style.show_underlines {
let diagnostic_color = super::diagnostic_style(severity, &editor_style.status);
diagnostic_highlight.underline = Some(UnderlineStyle {
color: Some(diagnostic_color),

View file

@ -1255,6 +1255,8 @@ pub struct Chunk<'a> {
pub diagnostic_severity: Option<lsp::DiagnosticSeverity>,
/// Whether this chunk of text is marked as unnecessary.
pub is_unnecessary: bool,
/// Whether this chunk of text should be underlined.
pub underline: bool,
/// Whether this chunk of text was originally a tab character.
pub is_tab: bool,
/// An optional recipe for how the chunk should be presented.
@ -1422,6 +1424,7 @@ impl<'a> Iterator for FoldChunks<'a> {
diagnostic_severity: chunk.diagnostic_severity,
is_unnecessary: chunk.is_unnecessary,
is_tab: chunk.is_tab,
underline: chunk.underline,
renderer: None,
});
}