Fix workspace-absolute paths in markdown images#52178
Closed
danielaalves01 wants to merge 1 commit intozed-industries:mainfrom
Closed
Fix workspace-absolute paths in markdown images#52178danielaalves01 wants to merge 1 commit intozed-industries:mainfrom
danielaalves01 wants to merge 1 commit intozed-industries:mainfrom
Conversation
Previously, markdown images failed to load workspace-absolute paths. This updates the parser to identify the active workspace root directory. Paths which are workspace absolute are correctly resolved and rendered. The added tests cover a successful resolution and fallback behaviour.
Member
|
Hey, thank you for working on this. We are refactoring how the markdown preview works in #52008, so that we don't have to maintain two markdown parsers. To make this easier to manage for us, I'm going to close this PR until we land the refactor (we plan to merge it at the end of the week). Please open a new PR once that has landed if the issue still persists. |
5 tasks
ConradIrwin
pushed a commit
that referenced
this pull request
Apr 1, 2026
## Context Previously, markdown images failed to load workspace-absolute paths. This updates the image resolver to identify the active workspace root directory. Paths which are workspace absolute are correctly resolved and rendered. The added test covers a successful resolution. This PR re-implements the fix that was originally proposed in my previous PR, #52178. ## Fix https://github.com/user-attachments/assets/d69644ea-06cc-4638-b4ee-ec9f3abbb1ed ## How to Review Small PR - focus on two changes in the file `crates/markdown_preview/src/markdown_preview_view.rs`: - `fn render_markdown_element()` (lines ~583-590): added the logic to determine the workspace_directory - `fn resolve_preview_image()` (lines ~714-726): added workspace_directory variable, and a verification to create the full path when a path is workspace-absolute One test was added, covering a successful resolution (`resolves_workspace_absolute_preview_images`). This test was implemented in the file `crates/markdown_preview/src/markdown_preview_view.rs`. ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [ ] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Closes #46924 Release Notes: - Added workspace-absolute path detection in markdown files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Previously, markdown images failed to load workspace-absolute paths. This fix updates the parser, making it able to identify the active workspace root directory. Paths which are workspace absolute are correctly resolved and rendered.
Closes #46924
How to Review
Small PR - focus on three changes in three different files:
crates/markdown_preview/src/markdown_elements.rs-identify()(~line 296-337): added workplace_directory variable, and a verification to create the full path when a path is workplace-absolutecrates/markdown_preview/src/markdown_parser.rs-parse_markdown()(~line 22): added workplace_directory variable to function's argumentscrates/markdown_preview/src/markdown_preview_view.rs-parse_markdown_in_background()(~line 344-359): added logic to determine the worplace_directoryTwo tests were added, one covering a successful resolution (
test_workspace_absolute_path_resolution) and another testing the fallback behaviour when given a path of a file that does not exist within the workspace (test_workspace_absolute_path_missing_file_fallback). Both tests are implemented in the filecrates/markdown_preview/src/markdown_parser.rs.Self-Review Checklist
Release Notes: