feat(better-ignore): Added Glob based (.gitignore-like) pattern support for the ignore paths setting + much better defaults#152
Conversation
- 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
There was a problem hiding this comment.
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
.gitignoresemantics for ignore patterns (including!negation) across full walks, rescans, and incremental (FSEvents) updates using theignorecrate. - 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.
|
Hey @ldm0, I explained it very well above. Thank you |
|
@maddada Thanks for your great effort! I will review it this weekend, currently busy with work 💦 . |
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.
Included in this PR:
**/node_modules/**to ignore all node_modules folders on their machine.Need your input here:
Added these 2 crates:
.gitignoreagainst file paths.All the best!