Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
markdown_preview: Improve the link decoration logic (#39905)
Bartosz Kaszubowski287314f41574
diff --git a/crates/markdown_preview/src/markdown_elements.rs b/crates/markdown_preview/src/markdown_elements.rsindex 827c11f0453..d0bde488891 100644--- a/crates/markdown_preview/src/markdown_elements.rs+++ b/crates/markdown_preview/src/markdown_elements.rs@@ -1,5 +1,5 @@use gpui::{- DefiniteLength, FontStyle, FontWeight, HighlightStyle, Hsla, SharedString, StrikethroughStyle,+ DefiniteLength, FontStyle, FontWeight, HighlightStyle, SharedString, StrikethroughStyle,UnderlineStyle, px,};use language::HighlightId;@@ -175,11 +175,7 @@ pub enum MarkdownHighlight {impl MarkdownHighlight {/// Converts this [`MarkdownHighlight`] to a [`HighlightStyle`].- pub fn to_highlight_style(- &self,- theme: &theme::SyntaxTheme,- link_color: Hsla,- ) -> Option<HighlightStyle> {+ pub fn to_highlight_style(&self, theme: &theme::SyntaxTheme) -> Option<HighlightStyle> {match self {MarkdownHighlight::Style(style) => {let mut highlight = HighlightStyle::default();@@ -209,10 +205,8 @@ impl MarkdownHighlight {if style.link {highlight.underline = Some(UnderlineStyle {thickness: px(1.),- color: Some(link_color),..Default::default()});- highlight.color = Some(link_color);}Some(highlight)diff --git a/crates/markdown_preview/src/markdown_renderer.rs b/crates/markdown_preview/src/markdown_renderer.rsindex 489ce532f00..6f794b1358a 100644--- a/crates/markdown_preview/src/markdown_renderer.rs+++ b/crates/markdown_preview/src/markdown_renderer.rs@@ -692,7 +692,7 @@ fn render_markdown_text(parsed_new: &MarkdownParagraph, cx: &mut RenderContext)let highlights = gpui::combine_highlights(parsed.highlights.iter().filter_map(|(range, highlight)| {highlight- .to_highlight_style(&syntax_theme, link_color)+ .to_highlight_style(&syntax_theme).map(|style| (range.clone(), style))}),parsed.regions.iter().zip(&parsed.region_ranges).filter_map(@@ -705,6 +705,14 @@ fn render_markdown_text(parsed_new: &MarkdownParagraph, cx: &mut RenderContext)..Default::default()},))+ } else if region.link.is_some() {+ Some((+ range.clone(),+ HighlightStyle {+ color: Some(link_color),+ ..Default::default()+ },+ ))} else {None}