Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
git_ui: Fix select previous selects a non-visible item (#49289)
Remco Smitscd1211f70d86
diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rsindex 7bd4f3b32a6..b9846e1df74 100644--- a/crates/git_ui/src/git_panel.rs+++ b/crates/git_ui/src/git_panel.rs@@ -1133,7 +1133,22 @@ impl GitPanel {}if matches!(self.entries.get(new_index), Some(GitListEntry::Header(..))) {- self.selected_entry = Some(new_index.saturating_sub(1));+ self.selected_entry = match &self.view_mode {+ GitPanelViewMode::Flat => Some(new_index.saturating_sub(1)),+ GitPanelViewMode::Tree(tree_view_state) => {+ maybe!({+ let current_logical_index = tree_view_state+ .logical_indices+ .iter()+ .position(|&i| i == new_index)?;++ tree_view_state+ .logical_indices+ .get(current_logical_index.saturating_sub(1))+ .copied()+ })+ }+ };} else {self.selected_entry = Some(new_index);}