Add VS Code-style "Group by Staging" mode to the git panel - #48668
Closed
PSU3D0 wants to merge 3 commits into
Closed
Add VS Code-style "Group by Staging" mode to the git panel#48668PSU3D0 wants to merge 3 commits into
PSU3D0 wants to merge 3 commits into
Conversation
Adds a new `git_panel.group_by` setting that controls how entries in the git panel are grouped. The default value `"status"` preserves the existing behavior (Conflicts / Tracked / Untracked). The new `"staging"` value groups entries into 'Staged Changes' and 'Changes' sections, similar to VS Code's Source Control panel. Key behaviors: - Partially staged files appear in both sections - Clicking a file under 'Staged Changes' opens a HEAD→Index diff - Clicking a file under 'Changes' opens an Index→Worktree diff - Toggle via right-click context menu in the git panel header - Setting persists in user settings.json Implementation: - New `DiffBase::Staged` and `DiffBase::Unstaged` variants for `BranchDiff` to load the correct diff type per section - New `open_staged_diff()` on `GitStore` that creates a read-only buffer with index content and diffs it against HEAD - `ProjectDiff::deploy_with_base()` to open/reuse ProjectDiff instances for each diff base variant - Git panel detects which section a clicked entry belongs to and opens the appropriate diff view Closes zed-industries#45295
|
please, we need it |
Member
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
Adds a VS Code-style "Group by Staging" mode to the git panel, allowing users to see their changes organized into Staged Changes and Changes sections instead of the current Conflicts / Tracked / Untracked grouping.
This is controlled by a new
git_panel.group_bysetting:{ "git_panel": { "group_by": "staging" } }Behavior
"status"(default): Preserves the existing grouping — Conflicts, Tracked, Untracked. No behavior change."staging": Groups entries into "Staged Changes" and "Changes" sections.Screenshots
Implementation
New setting (
settings_content,git_panel_settings)GitPanelGroupByenum withStatusandStagingvariantsgroup_byfield onGitPanelSettings, defaultStatusGit panel grouping (
git_panel.rs)Sectionenum withStaged/Unstagedvariantsupdate_visible_entries()classifies files byStageStatuswhengroup_by == Stagingsection_for_entry()walks backwards from a selected entry to find its section headeropen_diff()detects whether the clicked entry is in a Staged or Unstaged section and opens the appropriate diff viewToggleGroupByStagingaction + context menu entry for togglingDiff pipeline (
branch_diff.rs,git_store.rs,project_diff.rs)DiffBase::StagedandDiffBase::UnstagedvariantsBranchDiff::load_buffers()filters files by staging status for the new modesBranchDiff::load_buffer()dispatches to the correct diff loader per mode:Staged→GitStore::open_staged_diff()(new) — creates a read-only buffer with index content, diffs against HEADUnstaged→GitStore::open_unstaged_diff()(existing) — diffs index against worktreeHead/Merge→ existing behavior unchangedProjectDiff::deploy_with_base()opens or reuses a ProjectDiff for a givenDiffBasevariantTests
Release Notes:
git_panel.group_bysetting. When set to"staging", the git panel groups entries into "Staged Changes" and "Changes" sections (similar to VS Code). Clicking entries in each section shows the appropriate diff — staged changes show HEAD→Index, unstaged changes show Index→Worktree.