Skip to content

Commit be86d87

Browse files
committed
fix: always cap start page sessions and groups
The session list on the start page previously removed the MAX_RECENT_SESSIONS (3) per-group cap and MAX_VISIBLE_GROUPS (3) cap when a filter was active, causing the list to grow to full size while typing. Keep both caps applied unconditionally.
1 parent d365343 commit be86d87

1 file changed

Lines changed: 12 additions & 31 deletions

File tree

src/app.rs

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -830,24 +830,14 @@ impl App {
830830
let q = self.session_filter.to_lowercase();
831831
let mut items = Vec::new();
832832

833-
// When no filter is active, cap the number of visible groups.
834-
let cap_groups = q.is_empty();
835-
let hidden_groups = if cap_groups {
836-
self.session_groups.len().saturating_sub(MAX_VISIBLE_GROUPS)
837-
} else {
838-
0
839-
};
833+
// Cap the number of visible groups.
834+
let hidden_groups = self.session_groups.len().saturating_sub(MAX_VISIBLE_GROUPS);
840835

841-
let groups_iter: Box<dyn Iterator<Item = (usize, &SessionGroup)>> = if cap_groups {
842-
Box::new(
843-
self.session_groups
844-
.iter()
845-
.enumerate()
846-
.take(MAX_VISIBLE_GROUPS),
847-
)
848-
} else {
849-
Box::new(self.session_groups.iter().enumerate())
850-
};
836+
let groups_iter = self
837+
.session_groups
838+
.iter()
839+
.enumerate()
840+
.take(MAX_VISIBLE_GROUPS);
851841

852842
for (group_idx, group) in groups_iter {
853843
let collapse_key = group.cwd.clone().unwrap_or_default();
@@ -878,19 +868,10 @@ impl App {
878868
});
879869

880870
if !collapsed {
881-
// When a filter is active show all matches; otherwise cap at
882-
// MAX_RECENT_SESSIONS and append a ShowMore row if needed.
883-
let capped = q.is_empty();
884-
let visible: Vec<usize> = if capped {
885-
matching.iter().copied().take(MAX_RECENT_SESSIONS).collect()
886-
} else {
887-
matching.clone()
888-
};
889-
let hidden = if capped {
890-
matching.len().saturating_sub(MAX_RECENT_SESSIONS)
891-
} else {
892-
0
893-
};
871+
// Cap at MAX_RECENT_SESSIONS and append a ShowMore row if needed.
872+
let visible: Vec<usize> =
873+
matching.iter().copied().take(MAX_RECENT_SESSIONS).collect();
874+
let hidden = matching.len().saturating_sub(MAX_RECENT_SESSIONS);
894875

895876
for session_idx in visible {
896877
items.push(StartPageItem::Session {
@@ -905,7 +886,7 @@ impl App {
905886
}
906887
}
907888

908-
// Trailing ShowMore for hidden groups (only when filter is inactive).
889+
// Trailing ShowMore for hidden groups.
909890
if hidden_groups > 0 {
910891
items.push(StartPageItem::ShowMore {
911892
remaining: hidden_groups,

0 commit comments

Comments
 (0)