From ae50babfb44909ec89fb33d2cdddac3d0a3ab135 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Wed, 8 Jan 2025 14:15:45 -0500 Subject: [PATCH] Initialize the first repo when building the panel Co-Authored-By: Cole Miller <53574922+cole-miller@users.noreply.github.com> --- crates/git_ui/src/git_panel.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index efa7ca4545..e1c69fff99 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -183,6 +183,19 @@ impl GitPanel { let scroll_handle = UniformListScrollHandle::new(); + git_state.update(cx, |state, cx| { + let mut visible_worktrees = project.read(cx).visible_worktrees(cx); + let Some(first_worktree) = visible_worktrees.next() else { + return; + }; + drop(visible_worktrees); + let snapshot = first_worktree.read(cx).snapshot(); + + if let Some(repository) = first_worktree_repository(&project, snapshot.id(), cx) { + state.activate_repository(repository); + } + }); + let mut git_panel = Self { focus_handle: cx.focus_handle(), fs,