Prevent multibuffer items from switching active repository - #58795
Open
mengh04 wants to merge 4 commits into
Open
Prevent multibuffer items from switching active repository#58795mengh04 wants to merge 4 commits into
mengh04 wants to merge 4 commits into
Conversation
mengh04
force-pushed
the
fix-multirepo-git-panel-glitch
branch
from
June 7, 2026 23:08
cf47900 to
8de933d
Compare
mengh04
force-pushed
the
fix-multirepo-git-panel-glitch
branch
from
June 9, 2026 09:32
8de933d to
3da1662
Compare
When a multi-buffer item (e.g. ProjectDiff) gains focus, the workspace calls with the cursor's project path to automatically switch the active git repository. This was safe when multi-buffer items returned from , but PR zed-industries#57236 changed ProjectDiff to return the cursor-based path (for project panel highlighting), inadvertently allowing the cursor position to override the user's explicit repository selection. Fix the issue by restoring the Singleton guard that was removed in PR zed-industries#57236: only call when the active item is backed by a single buffer. Additionally, subscribe ProjectDiff to events so that its branch_diff updates when the user switches repos via the repository selector. Fixes zed-industries#58792
mengh04
force-pushed
the
fix-multirepo-git-panel-glitch
branch
from
July 11, 2026 20:05
3da1662 to
5814639
Compare
mengh04
force-pushed
the
fix-multirepo-git-panel-glitch
branch
from
August 1, 2026 17:01
e2daf3a to
81393c7
Compare
Contributor
Author
|
I've just added a regression test covering this fix. |
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.
Fixes the git panel's active repository being silently overridden by the cursor position in
ProjectDiff.Summary
When a multi-buffer item (e.g.
ProjectDiff) gains focus, the workspace callsset_active_repo_for_pathwith the cursor's project path to automatically switch the active git repository. This was safe when multi-buffer items returnedNonefromactive_project_path, but PR #57236 changedProjectDiffto return the cursor-based path (for project panel highlighting), inadvertently allowing the cursor position to override the user's explicit repository selection.Fix the issue by restoring the
Singletonguard that was removed in PR #57236: only callset_active_repo_for_pathwhen the active item is backed by a single buffer.Additionally, subscribe
ProjectDifftoActiveRepositoryChangedevents so that itsbranch_diffupdates when the user switches repos via the repository selector.Changes
workspace.rs: Only callset_active_repo_for_pathwhen the active item'sbuffer_kindisSingleton. Multi-buffer items (e.g.ProjectDiff, diagnostics, search results) span multiple repositories, so their cursor position should not trigger an automatic repository switch.project_diff.rs: Subscribe toGitStoreEvent::ActiveRepositoryChangedto keepbranch_diffin sync when the active repository is changed via the repository selector.Before
before.mp4
After
after.mp4
Closes #58792
Self-Review Checklist:
Release Notes: