From 9101f0ffc96a95b11f5d76e42b6ea73710f067f1 Mon Sep 17 00:00:00 2001 From: Remco Smits Date: Sat, 31 Jan 2026 19:54:18 +0100 Subject: [PATCH] git_ui: Fix visual optimistic staging bug for tree view (#48078) Before this PR we would not show the placeholder for the parent folders of a file entry inside the git tree view. This PR fixes that so it's visually correct. **Before** https://github.com/user-attachments/assets/3d0988de-f43b-4b2d-8f90-c531316ab290 **After** https://github.com/user-attachments/assets/e28f9eba-e301-4f9a-8647-7f1f2f12f87d Release Notes: - Git UI: Fix optimistic placeholder for folders in the three view --- crates/git_ui/src/git_panel.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 0bd1b46a5e909ff296a1fb359d3b586586cbc8f7..c57150355f11663d0ac37493a8331e78a04e8d65 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -1737,19 +1737,25 @@ impl GitPanel { return StageStatus::Unstaged; }; + let show_placeholders = self.show_placeholders && !self.has_staged_changes(); let mut fully_staged_count = 0usize; let mut any_staged_or_partially_staged = false; for descendant in descendants { - match GitPanel::stage_status_for_entry(descendant, repo) { - StageStatus::Staged => { - fully_staged_count += 1; - any_staged_or_partially_staged = true; - } - StageStatus::PartiallyStaged => { - any_staged_or_partially_staged = true; + if show_placeholders && !descendant.status.is_created() { + fully_staged_count += 1; + any_staged_or_partially_staged = true; + } else { + match GitPanel::stage_status_for_entry(descendant, repo) { + StageStatus::Staged => { + fully_staged_count += 1; + any_staged_or_partially_staged = true; + } + StageStatus::PartiallyStaged => { + any_staged_or_partially_staged = true; + } + StageStatus::Unstaged => {} } - StageStatus::Unstaged => {} } }