fix: normalize path separators for cross-platform keyword matching - #1264
Open
zad111ak-ai wants to merge 2 commits into
Open
fix: normalize path separators for cross-platform keyword matching#1264zad111ak-ai wants to merge 2 commits into
zad111ak-ai wants to merge 2 commits into
Conversation
added 2 commits
July 14, 2026 23:11
Normalize both stored paths and query keywords to use forward slashes before matching in filter_by_keywords. This ensures that on Windows: - cd bar/meow matches ~\foo\bar\meow - cd bar\meow matches ~/foo/bar/meow Unlike PR ajeetdsouza#1222 which only normalizes the path, this normalizes both sides of the match. Normalization is unconditional (harmless no-op on Linux/macOS) enabling cross-platform test execution. Added 7 new test cases for backslash path matching. Closes ajeetdsouza#1217
rustfmt requires splitting long function signatures across multiple lines. This was the only CI failure.
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
Normalizes both stored paths and query keywords to use forward slashes before matching in
filter_by_keywords. This ensures that on Windows:cd bar/meowmatches~\foo\bar\meow(forward slash query → backslash path)cd bar\\meowmatches~/foo/bar/meow(backslash query → forward slash path)Both directions work because normalization is applied to both sides of the match.
Changes
src/db/stream.rs: Replace\\with/in both path and keywords beforerfindmatching. Normalization is unconditional (nocfg!(windows)) so it's a harmless no-op on Linux/macOS and allows cross-platform test execution.Comparison with PR #1222
PR #1222 normalizes only the stored path but not the query keywords. This means
cd bar\\meow(backslash query) won't match a normalized path. This fix normalizes both sides.Regression test
All 23 tests pass (15 existing + 7 new backslash-path tests + 1 add test).
Closes #1217