Repository navigation
fix(watch): reindex only changed files; --filter restricts what is indexed - #584
Merged
Merged
Conversation
…is indexed detect_changes returned every source file on every tick and the whole project was reindexed after a trigger, so --filter only gated whether a cycle fired. The watch loop now keeps an (mtime, size) snapshot, diffs it each tick (new/modified/deleted), applies the ext/git-only/--filter/skip filters, and reindexes only the changed files via a new include predicate (IndexSession::index_matching). Deletions are pruned by the same run; idle ticks do no indexing work. Fixes both cora watch and index --watch. Closes #578 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: ajianaz <ajianaz@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #578
What
cora watch/index --watchkept no state:detect_changesreturned every source file each tick and the whole project was then incrementally indexed, so--filteronly gated whether a cycle fired.(mtime ns, size)snapshot of watched files (ext,--git-only,--filter, and the session's skip patternsignore.files/index_skip_files). Each tick diffs it: new/modified files are re-indexed, deleted files are detected and pruned by the same run. Idle ticks do no indexing work. The baseline is taken before the initial index, so the first cycle does not report everything as changed.index::index_project_filtered(..., include)/IndexSession::index_matching: an include predicate on the root-relative path. Non-included files are not read/reindexed but still count as present, so their rows are not pruned.index_project_with_skipdelegates withNone(no behavior change for other callers). IndexSession still owns config/skip patterns/backend.Why
detect_changesreturned every source file on each tick, so--filterwas only a trigger gate and every cycle ran a whole-project incremental index (found while smoke-testing #577).User-visible changes
--filternow restricts which files are reindexed, not just which cycles fire; modifying a non-matching file does nothing.Reindexed: N filesreflects only those). Flags and banner text unchanged.Testing
Unit tests in
commands/watch.rs: unchanged tree -> empty change set (baseline not all-changed); modified file is the only change; new + deleted detected;--filterignores non-matching changes; skip patterns respected; end-to-end with a real IndexSession: non-matching change -> nothing indexed, matching change -> exactly 1 file reindexed, deletion pruned only that file.Smoke test (debug binary, temp CODECORA_HOME/project):
watch --filter a.rs, append b.rs -> no output; append a.rs ->Reindexed: 1 files, 3 symbols updated.index --watch: append b.rs ->Reindexed: 1 files; rm a.rs -> pruned.fmt, clippy -D warnings, cargo test --features tree-sitter all pass.
🤖 Generated with Claude Code