From 9ffa368173d811b9f956b87fc77c0ea24434420b Mon Sep 17 00:00:00 2001 From: Francesc Elies Date: Mon, 20 Mar 2023 15:45:31 +0100 Subject: [PATCH 1/2] render diagnostics shows description but not code --- helix-term/src/ui/editor.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 7c22df747642..905b91e39e96 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -11,6 +11,7 @@ use crate::{ }; use helix_core::{ + diagnostic::NumberOrString, graphemes::{ ensure_grapheme_boundary_next_byte, next_grapheme_boundary, prev_grapheme_boundary, }, @@ -684,6 +685,14 @@ impl EditorView { }); let text = Text::styled(&diagnostic.message, style); lines.extend(text.lines); + let code = diagnostic.code.as_ref().map(|x| match x { + NumberOrString::Number(n) => format!("({n})"), + NumberOrString::String(s) => format!("({s})"), + }); + if let Some(code) = code { + let text = Text::styled(code, style); + lines.extend(text.lines); + } } let paragraph = Paragraph::new(lines) From d7491a00e350a1f13744678bd38115a4bd275f23 Mon Sep 17 00:00:00 2001 From: Francesc Elies Date: Tue, 21 Mar 2023 07:37:07 +0100 Subject: [PATCH 2/2] text is an overkill, use span Co-authored-by: Michael Davis --- helix-term/src/ui/editor.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 905b91e39e96..0b6ab04654b4 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -31,7 +31,7 @@ use helix_view::{ }; use std::{mem::take, num::NonZeroUsize, path::PathBuf, rc::Rc, sync::Arc}; -use tui::buffer::Buffer as Surface; +use tui::{buffer::Buffer as Surface, text::Span}; use super::statusline; use super::{document::LineDecoration, lsp::SignatureHelp}; @@ -690,8 +690,8 @@ impl EditorView { NumberOrString::String(s) => format!("({s})"), }); if let Some(code) = code { - let text = Text::styled(code, style); - lines.extend(text.lines); + let span = Span::styled(code, style); + lines.push(span.into()); } }