Skip to content

fix(watch): detect_changes returns every source file each cycle; --filter only gates the trigger #578

Description

@ajianaz

Problem. commands/watch.rs::detect_changes walks the project and returns every source file that passes the extension/git-only/glob filters on each debounce tick, rather than files that actually changed. After a trigger the whole project is incrementally indexed, so --filter only decides whether a cycle fires; it does not restrict which files get indexed.

Repro (verified on develop @ 1dd7ac4). Project with src/a.rs and src/b.rs; run cora watch --filter 'a.rs'; append a line to src/b.rs only. Output: Reindexed: 1 files, and the stored fingerprint for b.rs changes even though it does not match the filter.

Why it matters now. Before #577 a basename filter like a.rs never matched (anchored glob), so nothing triggered. Since #577 basename patterns match, so every 500 ms cycle triggers a full incremental index run. It is cheap per cycle (unchanged files are skipped by fingerprint) but is a poll over the whole tree. index --watch also uses this path since #576.

Direction. detect_changes should compare against the last-seen mtime/size (or use fs events) and return only changed files; --filter should limit which files are indexed, not just which cycles fire. Add tests that a change to a non-matching file produces no reindex.

Found while smoke-testing #577. Related: #576.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions