Trim diagnostic messages to fix rendering bug

Before this change a diagnostic message with a trailing newline (e.g.
`line1\nline2\n`) would be rendered in a `Block` with `line_height: 2`.
But the content we then display in this block had 3 "lines", which
pushed the content out of the block.

This fixes the issue by trimming the newlines at the end from the
diagnostics.

Co-authored-by: Antonio <antonio@zed.dev>
This commit is contained in:
Thorsten Ball 2024-01-23 10:34:38 +01:00
parent 5a9f1e4eb7
commit f8939fd859

View File

@ -3906,7 +3906,7 @@ impl Project {
source: diagnostic.source.clone(),
code: code.clone(),
severity: diagnostic.severity.unwrap_or(DiagnosticSeverity::ERROR),
message: diagnostic.message.clone(),
message: diagnostic.message.trim().to_string(),
group_id,
is_primary: true,
is_disk_based,
@ -3923,7 +3923,7 @@ impl Project {
source: diagnostic.source.clone(),
code: code.clone(),
severity: DiagnosticSeverity::INFORMATION,
message: info.message.clone(),
message: info.message.trim().to_string(),
group_id,
is_primary: false,
is_disk_based,