Trim diagnostic messages to fix rendering bug

Thorsten Ball and Antonio created

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>

Change summary

crates/project/src/project.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Detailed changes

crates/project/src/project.rs 🔗

@@ -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,