fix(watcher): stop endless refresh inside a linked worktree - #86
Open
BenLocal wants to merge 1 commit into
Open
Conversation
- Narrow the shared-gitdir watcher from `worktrees/**` to
`worktrees/*/{HEAD,gitdir,locked}`: the broad glob also matched every
worktree's private runtime state, and for a linked worktree that state IS
our own gitdir. Every refresh runs `git status`, which takes `index.lock`,
which classified as 'unknown' and forced another full refresh, which ran
`git status` again — observed on a large monorepo worktree as a lock
create/delete every ~1.5s (debounce + cooldown) that never stopped. Since
any non-'status' change invalidates the history search, an in-flight
search restarted from scratch each round and never returned a result.
The three entries `git worktree list` actually reports are the only ones
worth watching; from a main repo this also stops a sibling worktree's
routine git activity from forcing a full refresh here.
- Keep the pattern deliberately "complex": per the VS Code API contract a
RelativePattern containing path segments still creates a recursive
watcher, so this only tightens the filter — it does not downgrade to a
non-recursive watcher that would miss `worktrees/<name>/HEAD` entirely.
- Pin the registered patterns in a test: the failure mode is silent (no
error, just a UI that never settles), so a regression would otherwise
only surface as a bug report.
Signed-off-by: benshi <807629978@qq.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.
worktrees/**toworktrees/*/{HEAD,gitdir,locked}: the broad glob also matched every worktree's private runtime state, and for a linked worktree that state IS our own gitdir. Every refresh runsgit status, which takesindex.lock, which classified as 'unknown' and forced another full refresh, which rangit statusagain — observed on a large monorepo worktree as a lock create/delete every ~1.5s (debounce + cooldown) that never stopped. Since any non-'status' change invalidates the history search, an in-flight search restarted from scratch each round and never returned a result. The three entriesgit worktree listactually reports are the only ones worth watching; from a main repo this also stops a sibling worktree's routine git activity from forcing a full refresh here.worktrees/<name>/HEADentirely.