Skip to content

feat(better-ignore): Added Glob based (.gitignore-like) pattern support for the ignore paths setting + much better defaults#152

Open
maddada wants to merge 16 commits intocardisoft:masterfrom
maddada:feat/make-ignore-paths-use-glob-patterns
Open

feat(better-ignore): Added Glob based (.gitignore-like) pattern support for the ignore paths setting + much better defaults#152
maddada wants to merge 16 commits intocardisoft:masterfrom
maddada:feat/make-ignore-paths-use-glob-patterns

Conversation

@maddada
Copy link

@maddada maddada commented Mar 3, 2026

Hey there!
Really awesome job on Cardinal.

I was looking for months for a replacement for "Everything" on macOS but couldn't find one until I saw Cardinal.

This app does almost everything I need perfectly: it filters instantly, finds files in all locations, has performant sorting and scrolling, etc.

The main issue I was having was that it was listing a ton of useless files by default. I tried to hide all files that are in any node_modules folder using a pattern like "/node_modules/" but couldn't do this with the previous "ignore paths" implementation.

Note: This PR is mostly AI coded with Codex 5.3 xhigh. However, I'm a 10+ yoe full stack software engineer and I wrote a detailed plan and I'm responsible for the implementation. I will also take care of any changes required. I reviewed every change and tested the feature thoroughly from user prespective for a week before sending this PR.

2026-03-06_cardinal_08-56-01@2x 2026-03-04_cardinal_03-36-18@2x

Included in this PR:

  • Ability to use any glob style pattern to ignore certain paths (just like .gitignore works). User can now write **/node_modules/** to ignore all node_modules folders on their machine.
  • Extra: Added ability to export a TSV of all listed files to the bottom bar to allow running python scripts to go over the files and find patterns
    • I worked with Codex to come up with the new default ignore list using this exported file + rust scripts.
  • Tests for these features

Need your input here:

  • Please let me know what you think of the defaults ignores I added.
    • For my macbook it took the indexed files from 13 milltion to 4 million which sped up searching, memory usage, and indexing when the app is started substantially.
  • Let me know if we should take out the export feature, it's not 100% related to the glob ignores feature but it's very useful so I decided to keep it (it just adds 1 button in the bottom bar)
  • AI sometimes writes unnecessary comments, I left some of those to make code review easier, let me know and I can remove all of them no issue (you have edit access on the commit anyways so please change anything you don't like)
  • Can you please test backwards compatibility on your end? It should keep your current set ignored paths but I'm not sure if those work well as they are or what's the best course of action here.

Added these 2 crates:

  • https://crates.io/crates/ignore -> A fast library for efficiently matching ignore files such as .gitignore against file paths.
  • https://crates.io/crates/rfd -> A cross platform Rust library for using native file open/save dialogs. Used to show a file save dialog when exporting the files list tsv.

All the best!

maddada and others added 12 commits February 22, 2026 23:56
- Added support for .gitignore-style matching semantics in ignore paths.
- Introduced a new IgnoreMatcher to handle ignore patterns and their evaluation.
- Updated the useIgnorePaths hook to include a comprehensive set of default ignore paths.
- Enhanced validation and error messages for ignore paths in the UI.
- Implemented tests to verify the behavior of ignore patterns, including negation and directory pruning.
- Documented ignore pattern semantics and requirements in new markdown files.
…gnore-paths-use-glob-patterns

# Conflicts:
#	.gitignore
* refactor: replace AtomicBool with generic function for cancellation in WalkData

* feat: add new_scan method for active scanning process version management

* feat: make scanning process cancellable

Currently there are tree paths that full file system scanning could happen:
1. first boot with no cache on disk
2. pressing rescan button
3. watch config updated(root path or ignore paths)

This commit make the scanning process cancellable. People can interrupt scanning process by clicking rescan button or changing watch config in settings panel.

* fix: make noop EventWatcher.recv never return

* Remove unnecessary filter of handle_watch_config_update

When last update was cancelled, the watch root tracked in search cache will not be updated. If the next update uses the old(non updated) watch root, currently it will be filtered, which the make status bar stuck.

* test: add tests for CancellationToken behavior and scan token management

* feat: optimize watch config handling to prevent unnecessary updates

* refactor: add TODO to replace watch_root with cache's path in run_logic_thread

* feat: add noop method to SearchCache for handling cancellation scenarios

* refactor: remove existing cache even if current fswalk is cancelled

* fix: make initial search cache respect watch config change

* fix: Don't cerate event watcher when initial search cache building is cancelled

* test: add tests for noop watchers and watch config updates

* fix: simplify is_noop method by using is_empty for collections

* fix: update event watcher handling to use noop for no-op caches

* test: add tests for noop cache properties and walk_data propagation

* fix: update app state to 'Updating' when using noop event watcher
@ldm0 ldm0 requested review from Copilot and ldm0 and removed request for Copilot March 4, 2026 03:24
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR upgrades Cardinal’s “ignore paths” preference from simple path-prefix filtering to .gitignore-style glob/negation semantics (rooted at watchRoot), expands default ignore rules to reduce indexed noise, and adds a UI-driven TSV export of the currently listed files.

Changes:

  • Implement .gitignore semantics for ignore patterns (including ! negation) across full walks, rescans, and incremental (FSEvents) updates using the ignore crate.
  • Add a “Export current files list” action that writes a TSV via Tauri commands + a native save dialog (rfd).
  • Update defaults, UI copy, and tests to reflect the new ignore semantics and export behavior.

Reviewed changes

Copilot reviewed 28 out of 31 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
search-cache/tests/fsevent_incremental_tests.rs Adds incremental-scan tests for glob ignores + negation and updates ignored-path assertions.
search-cache/src/tests/wildcard_star.rs Small test formatting improvements.
search-cache/src/tests/query_logic.rs Test fixture refactor + formatting changes.
search-cache/src/tests/date_volume.rs Tightens “lastmonth” test expectation for stability.
search-cache/src/cache.rs Plumbs a shared IgnoreMatcher into scans/rescans and enforces ignored-ancestor pruning for incremental updates.
fswalk/tests/deep_walk.rs Replaces prefix-ignore integration tests with glob/negation semantics tests.
fswalk/src/lib.rs Introduces IgnoreMatcher backed by ignore::gitignore and updates walk pruning logic to use it.
fswalk/Cargo.toml Adds ignore dependency.
doc/inner/ignore-requirements-implemented.md Documents implemented ignore semantics and limitations.
doc/inner/ignore-patterns.md Adds detailed docs for ignore pattern semantics and default rules.
doc/inner/SUMMARY.md Adds new ignore documentation pages to the book summary.
cardinal/src/utils/watchRoot.ts Adds isIgnorePathInputValid stub for ignore input validation.
cardinal/src/utils/exportListedFilesTsv.ts Adds TSV formatting + filename helper utilities.
cardinal/src/utils/tests/watchRoot.test.ts Adds tests for ignore-path validation behavior.
cardinal/src/utils/tests/exportListedFilesTsv.test.ts Adds tests for TSV export formatting + filename generation.
cardinal/src/i18n/resources/en-US.json Updates ignore help/error text for glob semantics.
cardinal/src/i18n/resources/ar-SA.json Updates ignore error text for glob semantics.
cardinal/src/hooks/useIgnorePaths.ts Replaces prior minimal defaults with a large commented, data-driven default ignore set; preserves blank/comment lines.
cardinal/src/hooks/tests/useIgnorePaths.test.ts Updates tests for preserving whitespace/blank entries and validating new defaults.
cardinal/src/components/tests/PreferencesOverlay.test.tsx Adds tests for saving glob/relative ignores and preserving blank/comment lines; adds reset-ignore button test.
cardinal/src/components/StatusBar.tsx Adds export button plumbing to StatusBar.
cardinal/src/components/PreferencesOverlay.tsx Stops trimming ignore lines on save; adds ignore-reset button; uses new ignore validator.
cardinal/src/tests/App.contextMenu.test.tsx Adds tests for TSV export flow (happy path, cancel, error cleanup).
cardinal/src/App.tsx Implements TSV export flow and wires it into StatusBar.
cardinal/src/App.css CSS changes for preferences layout + reset button styling.
cardinal/src-tauri/src/lib.rs Registers new TSV export commands; changes default system ignore path.
cardinal/src-tauri/src/commands.rs Keeps ignore lines verbatim (plus ~ expansion); adds TSV export commands and dialog logic.
cardinal/src-tauri/Cargo.toml Adds rfd dependency.
cardinal/src-tauri/Cargo.lock Locks new rfd dependency tree.
Cargo.lock Locks new ignore dependency tree.
.gitignore Adds ignored/ ignore rule.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@maddada
Copy link
Author

maddada commented Mar 6, 2026

Hey @ldm0,
Hope you have the time to look at this PR and let me know what you think.

I explained it very well above.

Thank you

@ldm0
Copy link
Collaborator

ldm0 commented Mar 6, 2026

@maddada Thanks for your great effort! I will review it this weekend, currently busy with work 💦 .

@maddada maddada changed the title feat: Added Glob based (.gitignore-like) pattern support for the ignore paths setting + much better defaults feat(better-ignore): Added Glob based (.gitignore-like) pattern support for the ignore paths setting + much better defaults Mar 7, 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.

3 participants