Repository navigation
fix(desktop): resolve preview paths on macOS and Linux - #59
Merged
Merged
Conversation
The resolver assumed a Windows computer, so on macOS a POSIX path went through the Git Bash and drive-letter mapping and failed, and relative links and images got Windows separators. Resolution now takes the host explicitly: on Unix a path stays a POSIX path, still refusing network paths. main CI failed on this in preview_path::tests::pwsh_paths on the macOS runner.
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.
What and why
CI on
mainfailed on the Markdown preview merge:Rust (macos-latest), testpreview_path::tests::pwsh_paths(leftd:/users/runner/n.md, right/users/runner/n.md). Windows and the frontend passed.The test was a symptom of a real bug: the preview's path resolution assumed a Windows computer. On macOS a path such as
/Users/me/api/README.mdwas run through the Windows mapping (Git Bash/d/x, drive letters), so Ctrl+click on a Markdown file would have failed with "outside the Windows drives", and relative links and images in a document resolved toUsers\me\api\docs\a.md, a relative path with Windows separators that the backend refuses.preview_path.rs): resolution now takes the host as an explicitHost(Windows or Unix). On Unix a path stays a POSIX path: joined to the pane's folder,..clamped at/,~expanded, no drive letters, and//host/sharestill refused because terminal output can forge it.resolve_preview_pathpicks the host withcfg!(windows). The home folder is now passed in instead of read inside the function, which also removes the host-dependent test input that failed on the runner.links.ts):resolveRelativekeeps/separators and the leading/for a POSIX document path.How you checked it
cargo fmt --check,cargo clippy --all-targets -- -D warnings,cargo test: clean, 139 passed. The Windows-host tests now pinHost::Windowswith a fixed home folder, and six new tests pinHost::Unix(relative and absolute paths,~,..at the root, no drives or network paths, no WSL, missing folder), so both hosts are tested on any machine.pnpm turbo check test build: pass, 357 Vitest tests (four new for POSIXresolveRelative, written first and failing withUsers\me\api\docs\setup.md).pnpm version:check: pass.Known gaps
The preview has only been exercised by hand on Windows (Git Bash). macOS needs one manual pass: Ctrl+click a
.mdname, a relative link, a local image.zsh is treated like bash for the shell hook; nothing here changes that.
cargo fmt --check,cargo clippy -- -D warningsandcargo testpasspnpm turbo check test buildandpnpm version:checkpassBug fixes have a test that failed before the fix
No secrets, personal paths or machine names in the diff
Docs and
CHANGELOG.mdupdated if behaviour changed (the preview is unreleased, so no new entry)