Trim diagnostic messages to fix rendering bug (#4210)

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.

Release Notes:

- Fixed rendering multi-line diagnostic errors inside of the editor.
This commit is contained in:
Thorsten Ball 2024-01-23 11:58:45 +01:00 committed by GitHub
commit fc7458d13b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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,