fix(plugin): strengthen IDE refresh after worktree symlink switch#42
Merged
guodong-sq merged 1 commit intomainfrom Mar 21, 2026
Merged
fix(plugin): strengthen IDE refresh after worktree symlink switch#42guodong-sq merged 1 commit intomainfrom
guodong-sq merged 1 commit intomainfrom
Conversation
After atomically swapping the active worktree symlink, the IDE's VFS, editor, PSI, and git state could become stale because the project path string doesn't change — only the symlink target does. Phase 3 (VFS): Replace single-root VfsUtil.findFileByIoFile with LocalFileSystem.refreshNioFiles on all relevant paths (symlink, target, .git, main repo root) so VFS re-reads the symlink entry and rescans the new target tree. Explicitly refresh .git child for gitdir pointer. Phase 4 (Editor/PSI/UI): After document reload, reparse PSI trees, commit documents, drop PSI caches, fire a synthetic roots-changed event via ProjectRootManagerEx.makeRootsChange, then refresh Project View, editor notifications, and daemon code analyzer. Phase 5 (Git): Re-set VCS directory mappings to trigger git4idea's root re-detection pipeline before calling repo.update(), so the new .git gitdir pointer is re-read. Mark project root dirty in addition to markEverythingDirty for gutter indicator updates. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.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.
Summary
LocalFileSystem.refreshNioFilestargeting the symlink, its.gitchild, the new target, and the main repo root — so VFS re-reads the symlink entry and rescans the new target treerepo.update(), so the.gitfile's newgitdir:pointer is re-readFixes three symptoms after worktree switching:
Test plan
🤖 Generated with Claude Code