diff --git a/crates/diagnostics/src/diagnostic_renderer.rs b/crates/diagnostics/src/diagnostic_renderer.rs index c5537573c7..a59c01e6d2 100644 --- a/crates/diagnostics/src/diagnostic_renderer.rs +++ b/crates/diagnostics/src/diagnostic_renderer.rs @@ -3,7 +3,7 @@ use std::{ops::Range, sync::Arc}; use editor::{ Anchor, Editor, EditorSnapshot, ToOffset, display_map::{BlockContext, BlockPlacement, BlockProperties, BlockStyle}, - hover_markdown_style, + hover_popover::diagnostics_markdown_style, scroll::Autoscroll, }; use gpui::{AppContext, Entity, Focusable, WeakEntity}; @@ -215,16 +215,19 @@ impl DiagnosticBlock { .border_color(border_color) .max_w(max_width) .child( - MarkdownElement::new(self.markdown.clone(), hover_markdown_style(bcx.window, cx)) - .on_url_click({ - move |link, window, cx| { - editor - .update(cx, |editor, cx| { - Self::open_link(editor, &diagnostics_editor, link, window, cx) - }) - .ok(); - } - }), + MarkdownElement::new( + self.markdown.clone(), + diagnostics_markdown_style(bcx.window, cx), + ) + .on_url_click({ + move |link, window, cx| { + editor + .update(cx, |editor, cx| { + Self::open_link(editor, &diagnostics_editor, link, window, cx) + }) + .ok(); + } + }), ) .into_any_element() } diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rs index b8dfad0a6b..78d9416ff3 100644 --- a/crates/diagnostics/src/diagnostics.rs +++ b/crates/diagnostics/src/diagnostics.rs @@ -23,6 +23,7 @@ use language::{ Bias, Buffer, BufferRow, BufferSnapshot, DiagnosticEntry, Point, ToTreeSitterPoint, }; use lsp::DiagnosticSeverity; + use project::{DiagnosticSummary, Project, ProjectPath, project_settings::ProjectSettings}; use settings::Settings; use std::{ @@ -521,7 +522,7 @@ impl ProjectDiagnosticsEditor { markdown::MarkdownElement::rendered_text( markdown.clone(), cx, - editor::hover_markdown_style, + editor::hover_popover::diagnostics_markdown_style, ) }, ); diff --git a/crates/editor/src/hover_popover.rs b/crates/editor/src/hover_popover.rs index 5a42b57514..297abd5c37 100644 --- a/crates/editor/src/hover_popover.rs +++ b/crates/editor/src/hover_popover.rs @@ -622,6 +622,55 @@ pub fn hover_markdown_style(window: &Window, cx: &App) -> MarkdownStyle { let buffer_font_family = settings.buffer_font.family.clone(); let buffer_font_fallbacks = settings.buffer_font.fallbacks.clone(); + let mut base_text_style = window.text_style(); + base_text_style.refine(&TextStyleRefinement { + font_family: Some(ui_font_family.clone()), + font_fallbacks: ui_font_fallbacks, + color: Some(cx.theme().colors().editor_foreground), + ..Default::default() + }); + MarkdownStyle { + base_text_style, + code_block: StyleRefinement::default().my(rems(1.)).font_buffer(cx), + inline_code: TextStyleRefinement { + background_color: Some(cx.theme().colors().background), + font_family: Some(buffer_font_family), + font_fallbacks: buffer_font_fallbacks, + ..Default::default() + }, + rule_color: cx.theme().colors().border, + block_quote_border_color: Color::Muted.color(cx), + block_quote: TextStyleRefinement { + color: Some(Color::Muted.color(cx)), + ..Default::default() + }, + link: TextStyleRefinement { + color: Some(cx.theme().colors().editor_foreground), + underline: Some(gpui::UnderlineStyle { + thickness: px(1.), + color: Some(cx.theme().colors().editor_foreground), + wavy: false, + }), + ..Default::default() + }, + syntax: cx.theme().syntax().clone(), + selection_background_color: { cx.theme().players().local().selection }, + heading: StyleRefinement::default() + .font_weight(FontWeight::BOLD) + .text_base() + .mt(rems(1.)) + .mb_0(), + ..Default::default() + } +} + +pub fn diagnostics_markdown_style(window: &Window, cx: &App) -> MarkdownStyle { + let settings = ThemeSettings::get_global(cx); + let ui_font_family = settings.ui_font.family.clone(); + let ui_font_fallbacks = settings.ui_font.fallbacks.clone(); + let buffer_font_family = settings.buffer_font.family.clone(); + let buffer_font_fallbacks = settings.buffer_font.fallbacks.clone(); + let mut base_text_style = window.text_style(); base_text_style.refine(&TextStyleRefinement { font_family: Some(ui_font_family.clone()), @@ -659,7 +708,6 @@ pub fn hover_markdown_style(window: &Window, cx: &App) -> MarkdownStyle { heading: StyleRefinement::default() .font_weight(FontWeight::BOLD) .text_base() - .mt(rems(1.)) .mb_0(), ..Default::default() } @@ -951,7 +999,7 @@ impl DiagnosticPopover { .child( MarkdownElement::new( self.markdown.clone(), - hover_markdown_style(window, cx), + diagnostics_markdown_style(window, cx), ) .on_url_click(move |link, window, cx| { if let Some(renderer) = GlobalDiagnosticRenderer::global(cx) {