Skip DSL generation on branch switch by detecting git HEAD changes#2525
Draft
Skip DSL generation on branch switch by detecting git HEAD changes#2525
Conversation
When switching branches, VS Code sends hundreds of file change notifications that trigger parallel reload + DSL generation requests. This causes incorrect RBIs and deleted valid files due to stale server state. Detect branch switches by reading .git/HEAD on each file change event. If HEAD changed since last check, skip DSL generation (only reload). Normal user edits don't change HEAD, so they continue to trigger DSL generation as before. Fixes Shopify/team-ruby-dx#1429
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
When switching branches (especially in large repos like world), VS Code sends hundreds of
didChangeWatchedFilesnotifications. Previously, each notification triggeredtrigger_reload+ DSL generation, causing:This PR detects branch switches by reading
.git/HEADon each file change event. If HEAD changed since the last check, we skip DSL generation entirely (only reload). Normal user edits don't change HEAD, so they continue to trigger DSL generation as before.How it works
read_git_headreads.git/HEADdirectly (no shelling out to git — just a file read)git_head_changed?compares current HEAD to the last known valueTesting
Related