Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Re-allow diagnostics hovers to soft wrap
Julia678c188de0e3
diff --git a/crates/editor/src/hover_popover.rs b/crates/editor/src/hover_popover.rsindex df2570a8ef4..b45cdb6b017 100644--- a/crates/editor/src/hover_popover.rs+++ b/crates/editor/src/hover_popover.rs@@ -1,7 +1,7 @@use futures::FutureExt;use gpui::{actions,- elements::{Flex, MouseEventHandler, Padding, ParentElement, Text},+ elements::{Flex, MouseEventHandler, Padding, Text},impl_internal_actions,platform::{CursorStyle, MouseButton},AnyElement, AppContext, Axis, Element, ModelHandle, Task, ViewContext,@@ -378,8 +378,17 @@ impl DiagnosticPopover {let mut text_style = style.hover_popover.prose.clone();text_style.font_size = style.text.font_size;- let mut diagnostic_source_style = style.hover_popover.diagnostic_source.clone();- diagnostic_source_style.font_size = style.text.font_size;+ let diagnostic_source_style = style.hover_popover.diagnostic_source_highlight.clone();++ let text = match &self.local_diagnostic.diagnostic.source {+ Some(source) => Text::new(+ format!("{source}: {}", self.local_diagnostic.diagnostic.message),+ text_style,+ )+ .with_highlights(vec![(0..source.len(), diagnostic_source_style)]),++ None => Text::new(self.local_diagnostic.diagnostic.message.clone(), text_style),+ };let container_style = match self.local_diagnostic.diagnostic.severity {DiagnosticSeverity::HINT => style.hover_popover.info_container,@@ -392,18 +401,7 @@ impl DiagnosticPopover {let tooltip_style = cx.global::<Settings>().theme.tooltip.clone();MouseEventHandler::<DiagnosticPopover, _>::new(0, cx, |_, _| {- Flex::row()- .with_children(- self.local_diagnostic- .diagnostic- .source- .as_ref()- .map(|source| Text::new(format!("{source}: "), diagnostic_source_style)),- )- .with_child(- Text::new(self.local_diagnostic.diagnostic.message.clone(), text_style)- .with_soft_wrap(true),- )+ text.with_soft_wrap(true).contained().with_style(container_style)})diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rsindex 6edf69d0541..5f0e89b5bf9 100644--- a/crates/theme/src/theme.rs+++ b/crates/theme/src/theme.rs@@ -887,7 +887,7 @@ pub struct HoverPopover {pub error_container: ContainerStyle,pub block_style: ContainerStyle,pub prose: TextStyle,- pub diagnostic_source: TextStyle,+ pub diagnostic_source_highlight: HighlightStyle,pub highlight: Color,}diff --git a/styles/src/styleTree/hoverPopover.ts b/styles/src/styleTree/hoverPopover.tsindex 31e1d807788..fadd62db1d4 100644--- a/styles/src/styleTree/hoverPopover.ts+++ b/styles/src/styleTree/hoverPopover.ts@@ -40,7 +40,7 @@ export default function HoverPopover(colorScheme: ColorScheme) {padding: { top: 4 },},prose: text(layer, "sans", { size: "sm" }),- diagnosticSource: text(layer, "sans", { size: "sm", underline: true, color: foreground(layer, "accent") }),+ diagnosticSourceHighlight: { underline: true, color: foreground(layer, "accent") },highlight: colorScheme.ramps.neutral(0.5).alpha(0.2).hex(), // TODO: blend was used here. Replace with something better}}