fix: resolve path-style wikilinks on Windows backslash paths (#885)#886
Open
thfaix wants to merge 2 commits into
Open
fix: resolve path-style wikilinks on Windows backslash paths (#885)#886thfaix wants to merge 2 commits into
thfaix wants to merge 2 commits into
Conversation
findEntryByPathSuffix compared entry.path against forward-slash path suffixes, but entry.path carries OS-native separators (backslashes on Windows, via path.to_string_lossy in src-tauri). A backslash path never ends with a forward-slash suffix, so Pass-1 path-suffix resolution silently failed on Windows: [[folder/note]] links resolved to the wrong note (or not at all when no filename-stem fallback matched), and the click did nothing. Normalize entry.path with the existing normalizeFilesystemPath helper (already used by relativePathStem) before the endsWith comparison. Adds regression tests for Windows backslash entry paths, including the subfolder-disambiguation case that the filename-stem fallback could not mask. Fixes refactoringhq#885
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.
Summary
Path-style wikilinks (
[[folder/note]]) silently fail to resolve on Windows — clicking the link does nothing.resolveEntry's Pass-1findEntryByPathSuffix(src/utils/wikilink.ts) comparedentry.pathagainst path suffixes built with forward slashes (/folder/note.md):But
entry.pathcarries OS-native separators — on Windows it's produced bypath.to_string_lossy()insrc-tauri/src/vault/mod.rs, so it uses backslashes (folder\note.md). A backslash path never.endsWith()a forward-slash suffix, so the path-suffix pass never matched on Windows. Links then either fell through to the filename-stem pass (resolving to the wrong note when two notes share a filename across folders) or failed entirely, leaving the click dead.This is the ADR-0035 "Obsidian-style, zero-config path-suffix resolution" feature breaking on Windows.
Fix
Normalize
entry.pathwith the existingnormalizeFilesystemPathhelper (already used byrelativePathStem) before theendsWithcomparison — a one-helper change that brings path-suffix matching in line with the rest of the module.Tests
Added two regression tests in
src/utils/wikilink.test.tscovering Windows backslash entry paths, including the subfolder-disambiguation case the filename-stem fallback could not mask. Followed the repo's TDD process (red → green).Verified locally:
pnpm exec vitest run— 4461 passed (407 files)npx tsc --noEmit— cleannpx eslint src/utils/wikilink.ts src/utils/wikilink.test.ts— cleanI could not run the native pre-push lane locally (Playwright smoke /
cargo/ CodeScene PAT-gated steps); leaving those to CI.Repro
[[folder/note]]linking to a note in a subfolder.Navigation target not found: folder/note); after, the target note opens.Fixes #885