Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add inline code blocks in markdown preview (#7277)
Robin Pfäffle980d4f1003e8
diff --git a/crates/rich_text/src/rich_text.rs b/crates/rich_text/src/rich_text.rsindex f5ab38c4cef..1063d89db3d 100644--- a/crates/rich_text/src/rich_text.rs+++ b/crates/rich_text/src/rich_text.rs@@ -13,6 +13,7 @@ use util::RangeExt;pub enum Highlight {Code,Id(HighlightId),+ InlineCode(bool),Highlight(HighlightStyle),Mention,SelfMention,@@ -67,6 +68,23 @@ impl RichText {background_color: Some(code_background),..id.style(theme.syntax()).unwrap_or_default()},+ Highlight::InlineCode(link) => {+ if !*link {+ HighlightStyle {+ background_color: Some(code_background),+ ..Default::default()+ }+ } else {+ HighlightStyle {+ background_color: Some(code_background),+ underline: Some(UnderlineStyle {+ thickness: 1.0.into(),+ ..Default::default()+ }),+ ..Default::default()+ }+ }+ }Highlight::Highlight(highlight) => *highlight,Highlight::Mention => HighlightStyle {font_weight: Some(FontWeight::BOLD),@@ -184,22 +202,14 @@ pub fn render_markdown_mut(}Event::Code(t) => {text.push_str(t.as_ref());- if link_url.is_some() {- highlights.push((- prev_len..text.len(),- Highlight::Highlight(HighlightStyle {- underline: Some(UnderlineStyle {- thickness: 1.0.into(),- ..Default::default()- }),- ..Default::default()- }),- ));- }+ let is_link = link_url.is_some();+if let Some(link_url) = link_url.clone() {link_ranges.push(prev_len..text.len());link_urls.push(link_url);}++ highlights.push((prev_len..text.len(), Highlight::InlineCode(is_link)))}Event::Start(tag) => match tag {Tag::Paragraph => new_paragraph(text, &mut list_stack),