diff options
| author | akbash <akbash@herdr.dev> | 2026-09-08 17:51:59 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-08 17:51:59 +0300 |
| commit | 68c7b78ec237034cbb0e21c8666842ed7991641d (patch) | |
| tree | 3d5a63866fa785a3307959301f3022fa21bff5ed /src/client/shell/sidebar.rs | |
| parent | ffa0892ef87d927eef78fe8068de4d90201fb20b (diff) | |
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 <ogulcancelik@gmail.com>
Diffstat (limited to 'src/client/shell/sidebar.rs')
| -rw-r--r-- | src/client/shell/sidebar.rs | 58 |
1 files changed, 40 insertions, 18 deletions
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<String> { +fn parent_group_key(snapshot: &ClientShellSnapshot, index: usize) -> Option<String> { 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<String>, + 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<String>, |
