From afe23cf85ad5f54c4a0b915f4ffae6ec7e0a832f Mon Sep 17 00:00:00 2001 From: hrou0003 <54772688+hrou0003@users.noreply.github.com> Date: Thu, 22 May 2025 02:57:51 +1000 Subject: [PATCH] Canonicalize markdown link paths (#29119) Closes #28657 Release Notes: - Fixed markdown preview not canonicalizing file paths --- crates/markdown_preview/Cargo.toml | 1 + crates/markdown_preview/src/markdown_renderer.rs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/markdown_preview/Cargo.toml b/crates/markdown_preview/Cargo.toml index 3b95b42ed5..ebdd8a9eb6 100644 --- a/crates/markdown_preview/Cargo.toml +++ b/crates/markdown_preview/Cargo.toml @@ -31,6 +31,7 @@ ui.workspace = true util.workspace = true workspace.workspace = true workspace-hack.workspace = true +fs.workspace = true [dev-dependencies] editor = { workspace = true, features = ["test-support"] } diff --git a/crates/markdown_preview/src/markdown_renderer.rs b/crates/markdown_preview/src/markdown_renderer.rs index b1ec4dc09e..80bed8a6e8 100644 --- a/crates/markdown_preview/src/markdown_renderer.rs +++ b/crates/markdown_preview/src/markdown_renderer.rs @@ -4,6 +4,7 @@ use crate::markdown_elements::{ ParsedMarkdownHeading, ParsedMarkdownListItem, ParsedMarkdownListItemType, ParsedMarkdownTable, ParsedMarkdownTableAlignment, ParsedMarkdownTableRow, }; +use fs::normalize_path; use gpui::{ AbsoluteLength, AnyElement, App, AppContext as _, ClipboardItem, Context, DefiniteLength, Div, Element, ElementId, Entity, HighlightStyle, Hsla, ImageSource, InteractiveText, IntoElement, @@ -680,7 +681,7 @@ fn render_markdown_text(parsed_new: &MarkdownParagraph, cx: &mut RenderContext) _ = workspace.update(cx, |workspace, cx| { workspace .open_abs_path( - path.clone(), + normalize_path(path.clone().as_path()), OpenOptions { visible: Some(OpenVisible::None), ..Default::default()