From 1a432b61ee4f52f3ff0da1c991aa5d605f700869 Mon Sep 17 00:00:00 2001 From: 依云 Date: Wed, 14 Feb 2024 02:33:23 +0800 Subject: fix(ui): don't preserve for empty space (#1712) For the following situation: $ atuin search -i --inline-height 15 [ HOST ] query > 1m 19d ago item 1 1 0s 1mo ago item 2 2 0s 1mo ago item 3 3 0s 1mo ago item 4 4 0s 1mo ago item 5 5 0s 1mo ago item 6 Atuin v17.2.1 [...] Scrolling item 6 results: [ HOST ] query 0s 1mo ago item 3 0s 1mo ago item 4 0s 1mo ago item 5 > 0s 1mo ago item 6 Atuin v17.2.1 [...] With this patch it becomes: [ HOST ] query 1m 19d ago item 1 0s 1mo ago item 2 0s 1mo ago item 3 0s 1mo ago item 4 0s 1mo ago item 5 > 0s 1mo ago item 6 Atuin v17.2.1 [...] --- atuin/src/command/client/search/history_list.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atuin/src/command/client/search/history_list.rs b/atuin/src/command/client/search/history_list.rs index 488ed89f..e27d0ce2 100644 --- a/atuin/src/command/client/search/history_list.rs +++ b/atuin/src/command/client/search/history_list.rs @@ -109,7 +109,7 @@ impl<'a> HistoryList<'a> { fn get_items_bounds(&self, selected: usize, offset: usize, height: usize) -> (usize, usize) { let offset = offset.min(self.history.len().saturating_sub(1)); - let max_scroll_space = height.min(10); + let max_scroll_space = height.min(10).min(self.history.len() - selected); if offset + height < selected + max_scroll_space { let end = selected + max_scroll_space; (end - height, end) -- cgit v1.3.1