Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@stuartsaunders
Copy link
Contributor

Description

I encountered a bug where filtering was not working as expected. When --include was used (e.g., -i "*.yml"), files with other extensions (like .rs or .lock) were still in the output.

The root cause appears to be with the add_custom_ignore_filename method in WalkBuilder. It looks like this method is meant for adding custom ignore file names, such as .gitignore, rather than filtering files using glob patterns.

Using the Homebrew binary

➜ glimpse -i "*.yml"

Token Count Summary:
Total tokens: 114,145

Breakdown by file:
  languages.yml: 52,838
  Cargo.lock: 36,912
  src/analyzer.rs: 4,559
  src/url_processor.rs: 2,982
  src/output.rs: 2,621
  src/file_picker.rs: 2,552
  readme.md: 1,735
  src/main.rs: 1,592
  src/config.rs: 1,402
  src/cli.rs: 1,258
  src/source_detection.rs: 1,133
  src/git_processor.rs: 1,068
  flake.lock: 886
  src/tokenizer.rs: 762
  build.rs: 648

After the fix in this PR

glimpse on  fix/include-filtering is 📦 0.7.5 via 🦀 1.82.0 took 2.2s
➜ ~/.local/bin/glimpse -i "*.yml"

Token Count Summary:
Total tokens: 52,838

Breakdown by file:
  languages.yml: 52,838

Solution

The filtering logic has been updated to use ignore::overrides::OverrideBuilder for both include and exclude patterns.

  • Include patterns (-i) are now added to the OverrideBuilder as positive patterns.
  • Exclude patterns (-e) continue to be added as negative patterns (with a !).

Updates the file filtering logic to properly use OverrideBuilder for include patterns.
@seatedro
Copy link
Owner

seatedro commented Jun 4, 2025

sweet!! also thank u for the tests

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.

2 participants