Commit 2f1e51e
authored
feat(windows): support both "\" and "/" for path separator on windows (#442)
* fix(windows): treat backslash as path separator in constraint matching
Indexed paths keep the OS-native separator (\\ on Windows) so that pathdiff, strip_prefix and watcher event lookups all stay byte-identical. Queries and constraints always use /, so path_contains_segment and path_ends_with_suffix now fold / and \\ together when walking boundaries and comparing slices. Glob matching gets a localized / rewrite at the call site because globset operates on strings.
Adds windows-latest to the Rust test matrix with a focused regression test covering PathSegment, FilePath and Glob constraints across grep, multi_grep and fuzzy_search. Also gates the unix-only write_relative_cstr / MMAP_THRESHOLD so -D warnings compiles on Windows.
Fixes #381
* test(windows): canonicalize tmp base in tests that rely on path equality
Three pre-existing tests compared picker-internal (canonical) paths against tmp.path()-derived (potentially 8.3 short-name) paths and silently passed on Linux/macOS. Match the picker's dunce canonicalization in each test so watch_dir, overflow and libgit2-workdir assertions hold on Windows too.
score.rs also now detects a forward slash in the query (on top of MAIN_SEPARATOR) so a path-like query enables the path-alignment bonus on Windows.
* fix(windows): canonicalize non-matching event paths in file picker lookups
FilePicker canonicalizes its base via dunce but watcher events, consumer calls and tests may still pass short-name / different-casing paths. to_relative_path, find_file_index and add_new_file now fall back to canonicalize (or parent canonicalize for deleted files) on Windows, keeping native separators in storage while still resolving non-matching prefixes.
* fix(windows): translate '/' to '\\' in fuzzy query parts on Windows
Stored paths keep the native separator, so a user query like 'src/core/file.rs' fails the byte-wise frizbee match against 'src\\core\\file.rs'. Translate forward slashes to backslashes only when the query uses them, inside both score_files and score_dirs, so full-path queries still rank the closest path match first.
* test(windows): compare fuzzy results by filename in fuzzy_and_grep_combined
edit_name/del_name come from repo_files with forward-slash relative paths, but stored paths on Windows use backslashes, so p.contains(edit_name) never matched. Fall back to file_name() which is separator-agnostic.
* chore: Update docs for - test(windows): compare fuzzy results by filename in fuzzy_and_grep_combined
* test(windows): accept backslash separators in path-shape assertions
grep_with_path_constraint, grep_with_negated_path_constraint and the watcher burst test asserted on relative paths with forward-slash prefixes. Stored paths on Windows use '\\', so accept either form.
* refactor(constraints): gate backslash separator handling to Windows
is_path_sep only folds '\\' on Windows and the two backslash-specific tests are #[cfg(windows)]. Removed verbose examples from the rustdoc on path_contains_segment / path_ends_with_suffix now that the behaviour is covered by the unit tests.1 parent 52b1e86 commit 2f1e51e
12 files changed
Lines changed: 506 additions & 61 deletions
File tree
- .github/workflows
- crates/fff-core
- src
- tests
- doc
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | | - | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | | - | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
52 | 71 | | |
53 | 72 | | |
54 | 73 | | |
| |||
59 | 78 | | |
60 | 79 | | |
61 | 80 | | |
62 | | - | |
63 | | - | |
| 81 | + | |
64 | 82 | | |
65 | 83 | | |
66 | 84 | | |
67 | 85 | | |
68 | | - | |
| 86 | + | |
69 | 87 | | |
70 | 88 | | |
71 | 89 | | |
72 | | - | |
73 | | - | |
74 | | - | |
| 90 | + | |
| 91 | + | |
75 | 92 | | |
76 | 93 | | |
77 | 94 | | |
78 | 95 | | |
79 | 96 | | |
80 | 97 | | |
81 | | - | |
82 | 98 | | |
83 | | - | |
| 99 | + | |
84 | 100 | | |
85 | 101 | | |
86 | 102 | | |
| |||
94 | 110 | | |
95 | 111 | | |
96 | 112 | | |
97 | | - | |
98 | | - | |
99 | 113 | | |
100 | 114 | | |
101 | 115 | | |
102 | 116 | | |
103 | 117 | | |
104 | 118 | | |
105 | | - | |
| 119 | + | |
106 | 120 | | |
107 | 121 | | |
108 | 122 | | |
109 | 123 | | |
110 | 124 | | |
111 | 125 | | |
112 | | - | |
113 | 126 | | |
114 | | - | |
| 127 | + | |
115 | 128 | | |
116 | | - | |
| 129 | + | |
117 | 130 | | |
118 | 131 | | |
119 | 132 | | |
120 | 133 | | |
121 | | - | |
122 | 134 | | |
123 | 135 | | |
124 | 136 | | |
125 | 137 | | |
126 | 138 | | |
127 | | - | |
| 139 | + | |
128 | 140 | | |
129 | 141 | | |
130 | 142 | | |
131 | | - | |
| 143 | + | |
132 | 144 | | |
133 | 145 | | |
134 | | - | |
| 146 | + | |
135 | 147 | | |
136 | 148 | | |
137 | 149 | | |
| |||
249 | 261 | | |
250 | 262 | | |
251 | 263 | | |
| 264 | + | |
| 265 | + | |
252 | 266 | | |
253 | 267 | | |
254 | 268 | | |
255 | 269 | | |
256 | 270 | | |
257 | 271 | | |
258 | 272 | | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
259 | 279 | | |
260 | 280 | | |
261 | 281 | | |
| |||
536 | 556 | | |
537 | 557 | | |
538 | 558 | | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
539 | 585 | | |
540 | 586 | | |
541 | 587 | | |
| |||
580 | 626 | | |
581 | 627 | | |
582 | 628 | | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
583 | 646 | | |
584 | 647 | | |
585 | 648 | | |
| |||
0 commit comments