Skip to content

fix: exclude patterns ignored when scanning directories #125

Open
2-towns wants to merge 3 commits into
arnetheduck:masterfrom
2-towns:fix/exclude-pattern-dir-scan
Open

fix: exclude patterns ignored when scanning directories #125
2-towns wants to merge 3 commits into
arnetheduck:masterfrom
2-towns:fix/exclude-pattern-dir-scan

Conversation

@2-towns

@2-towns 2-towns commented Apr 30, 2026

Copy link
Copy Markdown

When passing a directory to nph, files found by walkDirRec were added to explicitFiles, causing exclude patterns to be bypassed entirely. Files in nimbledeps/ (and other default exclusions) were formatted when they shouldn't .

The fix defers directory walking to after patterns are compiled, applying exclusions to paths relative to the passed directory.

To reproduce:

mkdir -p /tmp/test_nph_exclude/nimbledeps                                                                                
echo 'let x=1' > /tmp/test_nph_exclude/main.nim                                                                        
echo 'let x=1' > /tmp/test_nph_exclude/nimbledeps/foo.nim

nph --check /tmp/test_nph_exclude products:

arnaud@fedora:/tmp/test_nph_exclude$ /home/arnaud/Work/logos/nph/nph --check .  
would reformat ./main.nim
would reformat ./nimbledeps/foo.nim

Oh no! 💥 💔 💥
2 files would be reformatted.

After the fix:

arnaud@fedora:/tmp/test_nph_exclude$ /home/arnaud/Work/logos/nph/nph --check .  
would reformat ./main.nim

Oh no! 💥 💔 💥
1 file would be reformatted.

@2-towns 2-towns changed the title fix: remove explicit files added during walk dir fix: exclude patterns ignored when scanning directories May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant