diff options
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>, |
