From 68c7b78ec237034cbb0e21c8666842ed7991641d Mon Sep 17 00:00:00 2001 From: akbash Date: Tue, 8 Sep 2026 17:51:59 +0300 Subject: fix: collapse worktree groups with saved machines (#3781) * fix: collapse worktree groups with saved machines refs #3778 * fix: scope worktree collapse by machine refs #3778 * fix: collapse machines without switching focus refs #3778 --------- Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com> Co-authored-by: Ogulcan Celik --- src/client/shell/sidebar.rs | 58 +++++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 18 deletions(-) (limited to 'src/client/shell/sidebar.rs') diff --git a/src/client/shell/sidebar.rs b/src/client/shell/sidebar.rs index 0aaa0d51..fe6abf00 100644 --- a/src/client/shell/sidebar.rs +++ b/src/client/shell/sidebar.rs @@ -316,22 +316,14 @@ pub(crate) fn render_sidebar( dragged, palette, ); - let group_toggle = parent_group_key(snapshot, entry.index).map(|key| { - let rect = Rect::new(rect.right().saturating_sub(1), rect.y, 1, 1); - put_text( - buffer, - rect.x, - rect.y, - rect.width, - if state.collapsed_groups.contains(&key) { - "▸" - } else { - "▾" - }, - Style::default().fg(palette.accent), - ); - (rect, key) - }); + let group_toggle = render_parent_group_toggle( + buffer, + rect, + snapshot, + entry.index, + state.collapsed_groups, + palette, + ); hits.workspaces.push(WorkspaceHit { rect, endpoint_id: ClientEndpointId::Local, @@ -534,7 +526,7 @@ pub(crate) fn workspace_entries( entries } -pub(super) fn parent_group_key(snapshot: &ClientShellSnapshot, index: usize) -> Option { +fn parent_group_key(snapshot: &ClientShellSnapshot, index: usize) -> Option { let workspace = snapshot.workspaces.get(index)?; let worktree = workspace.worktree.as_ref()?; if worktree.is_linked_worktree { @@ -554,7 +546,37 @@ pub(super) fn parent_group_key(snapshot: &ClientShellSnapshot, index: usize) -> .then(|| worktree.key.clone()) } -pub(super) fn displayed_workspace_status( +pub(in crate::client::shell) fn render_parent_group_toggle( + buffer: &mut Buffer, + workspace_rect: Rect, + snapshot: &ClientShellSnapshot, + workspace_index: usize, + collapsed_groups: &HashSet, + palette: &Palette, +) -> Option<(Rect, String)> { + let key = parent_group_key(snapshot, workspace_index)?; + let toggle = Rect::new( + workspace_rect.right().saturating_sub(1), + workspace_rect.y, + 1, + 1, + ); + put_text( + buffer, + toggle.x, + toggle.y, + toggle.width, + if collapsed_groups.contains(&key) { + "▸" + } else { + "▾" + }, + Style::default().fg(palette.accent), + ); + Some((toggle, key)) +} + +pub(in crate::client::shell) fn displayed_workspace_status( snapshot: &ClientShellSnapshot, workspace: &ClientShellWorkspace, collapsed_groups: &HashSet, -- cgit v1.2.3