From 7db744ab4758df30f3e811ff9930646ec5f5970d Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Fri, 31 Jul 2026 15:40:20 +0300 Subject: [PATCH] fix(sidebar): keep worktree groups packed --- .../website/src/data/config-reference.json | 2 +- src/ui/sidebar.rs | 23 +++++++------------ 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/docs/next/website/src/data/config-reference.json b/docs/next/website/src/data/config-reference.json index 4ad61f01..14549a22 100644 --- a/docs/next/website/src/data/config-reference.json +++ b/docs/next/website/src/data/config-reference.json @@ -702,7 +702,7 @@ "key": "ui.sidebar.spaces.row_gap", "type": "integer", "default": "0", - "description": "Blank terminal rows between expanded Space sidebar entries. Set to 1 to restore the previous spacing. Consecutive indented worktree children remain packed as one group." + "description": "Blank terminal rows between worktree groups and unrelated top-level Spaces. Worktree parents and their indented children remain packed." }, { "key": "ui.sidebar.spaces.rows", diff --git a/src/ui/sidebar.rs b/src/ui/sidebar.rs index 0a2b64ce..395bb2c3 100644 --- a/src/ui/sidebar.rs +++ b/src/ui/sidebar.rs @@ -230,15 +230,8 @@ fn workspace_row_height_in_body( workspace_row_height(app, workspace, indented).min(body_height) } -fn workspace_entry_gap( - app: &AppState, - entries: &[WorkspaceListEntry], - entry_idx: usize, - indented: bool, -) -> u16 { - if entry_idx + 1 < entries.len() - && !(indented && next_entry_is_indented_workspace(entries, entry_idx)) - { +fn workspace_entry_gap(app: &AppState, entries: &[WorkspaceListEntry], entry_idx: usize) -> u16 { + if entry_idx + 1 < entries.len() && !next_entry_is_indented_workspace(entries, entry_idx) { app.sidebar_spaces.row_gap } else { 0 @@ -476,7 +469,7 @@ fn workspace_list_visible_count(app: &AppState, area: Rect, scroll: usize) -> us }; ( workspace_row_height_in_body(app, ws, *indented, body.height), - workspace_entry_gap(app, &entries, entry_idx, *indented), + workspace_entry_gap(app, &entries, entry_idx), ) } }; @@ -500,7 +493,7 @@ fn workspace_list_bottom_start(app: &AppState, area: Rect) -> usize { let Some(workspace) = app.workspaces.get(*ws_idx) else { continue; }; - let gap = workspace_entry_gap(app, &entries, entry_idx, *indented); + let gap = workspace_entry_gap(app, &entries, entry_idx); let needed = workspace_row_height_in_body(app, workspace, *indented, body.height) .saturating_add(gap); if used_rows.saturating_add(needed) > body.height { @@ -691,7 +684,7 @@ pub(crate) fn compute_workspace_list_areas( continue; }; let row_height = workspace_row_height_in_body(app, ws, *indented, body.height); - let gap = workspace_entry_gap(app, &entries, entry_idx, *indented); + let gap = workspace_entry_gap(app, &entries, entry_idx); if row_y.saturating_add(row_height) > body_bottom { break; } @@ -2488,7 +2481,7 @@ rows = [[{ token = "git_status", fg = "#123456" }]] assert!(!cards[0].indented); assert_eq!(cards[1].ws_idx, 1); assert!(cards[1].indented); - assert_eq!(cards[1].rect.y, cards[0].rect.y + cards[0].rect.height + 1); + assert_eq!(cards[1].rect.y, cards[0].rect.y + cards[0].rect.height); } #[test] @@ -2506,7 +2499,7 @@ rows = [[{ token = "git_status", fg = "#123456" }]] let (spacious, _) = compute_workspace_list_areas(&app, Rect::new(0, 0, 30, 30)); assert_eq!( spacious[1].rect.y, - spacious[0].rect.y + spacious[0].rect.height + 2 + spacious[0].rect.y + spacious[0].rect.height ); assert_eq!( spacious[2].rect.y, @@ -2517,7 +2510,7 @@ rows = [[{ token = "git_status", fg = "#123456" }]] spacious[2].rect.y + spacious[2].rect.height + 2 ); let spacious_metrics = workspace_list_scroll_metrics(&app, Rect::new(0, 0, 30, 7)); - assert_eq!(spacious_metrics.viewport_rows, 2); + assert_eq!(spacious_metrics.viewport_rows, 3); assert_eq!(spacious_metrics.max_offset_from_bottom, 2); app.sidebar_spaces.row_gap = 0;