natecraddock / zf

a commandline fuzzy finder and zig package designed for filtering filepaths
MIT License
451 stars 14 forks source link

-f, --filter differs from interactive #28

Closed Pistos closed 1 year ago

Pistos commented 1 year ago

If I have a project with some zig files (extension .zig), if I just manually type .zig into zf, the results differ from passing -f .zig

 % find . -type f | /home/dev/git/zf/zig-out/bin/zf
> .zig
./src/ui.zig
./src/lib.zig
./src/clib.zig
./src/main.zig
./src/term.zig
./lib/ziglyph/src/category/mark.zig
./lib/ziglyph/src/segmenter/Word.zig
./build.zig
./lib/ziglyph/build.zig
./lib/ziglyph/src/ascii.zig

find . -type f | /home/dev/git/zf/zig-out/bin/zf -f .zig
[...]
./.git/modules/lib/ziglyph/info/exclude
./.git/modules/lib/ziglyph/refs/heads/main
./.git/modules/lib/ziglyph/hooks/update.sample
./.git/modules/lib/ziglyph/logs/refs/heads/main
./.git/modules/lib/ziglyph/hooks/pre-push.sample
./.git/modules/lib/ziglyph/hooks/commit-msg.sample
[...]

So, it looks like the -f option is matching:

natecraddock commented 1 year ago
❯ find . -type f | zig-out/bin/zf -f ".zig" | wc -l
     108
❯ find . -type f | zig-out/bin/zf
> .zig                                                       108/146

Looks to me the results are the same? 108 matched lines in the same order for me

But yes, .zig does match the string ./.git/modules/lib/ziglyph/info/exclude because after the strict path matching fails (the filename exclude does not match .zig), matching is retried over the full string.

Pistos commented 1 year ago

Ah, you're right. I got misled by the number of results shown.

natecraddock commented 1 year ago

No worries!