Fix get_changed_files sourceControlState ignored (#269452)#3383
Open
pedrocostadev wants to merge 2 commits intomicrosoft:mainfrom
Open
Fix get_changed_files sourceControlState ignored (#269452)#3383pedrocostadev wants to merge 2 commits intomicrosoft:mainfrom
pedrocostadev wants to merge 2 commits intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where get_changed_files returns stale results for unstaged changes because the changes property was capturing array references at construction time instead of fetching fresh values from the Git repository state.
Changes:
- Convert
changesfrom a static readonly property to a getter inRepoContextImplto ensure fresh repository state is retrieved on each access
Convert `changes` from static property to getter so fresh values are fetched from repo state each access. Fixes microsoft/vscode#269452 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2929615 to
fc7587f
Compare
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.
Problem
get_changed_filesreturns stale/empty results forunstagedchanges because thechangesobject inRepoContextImplcaptures array references at construction time rather than fetching fresh values.When the Git extension updates repo state, it creates NEW arrays. The
changesobject still references the OLD arrays.Root Cause
File:
src/platform/git/vscode/gitServiceImpl.tsFix
Convert
changesfrom a static property to a getter so fresh values are fetched from_repo.stateeach access:Testing
npm run test:unit -- src/platform/git)RepoContextunchanged (getter is compatible with readonly property)Fixes microsoft/vscode#269452