mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 13:53:10 +00:00
Make history pager use more entries (#9458)
Like I mentioned in #9089, 12 entries is a bit few. So, instead, we do like we do for completions before disclosing and pick half the screen (but at least X, in this case 12). This avoids filling the entire screen, and will avoid an unsightly "X more entries" (which requires scrolling down to fully disclose) because it matches what the pager does. Note: For multiline commands we can be pushed further upwards, and in case of a multi-column layout we could fit more lines. That would require asking the pager to fit as many as possible and give us back the index of the last matching entry and rewinding the history search. That's gonna be left as an exercise for later if it turns out to be necessary.
This commit is contained in:
parent
51bce422fd
commit
5792e4a12b
1 changed files with 8 additions and 3 deletions
|
@ -1277,9 +1277,14 @@ static history_pager_result_t history_pager_search(const std::shared_ptr<history
|
||||||
history_search_direction_t direction,
|
history_search_direction_t direction,
|
||||||
size_t history_index,
|
size_t history_index,
|
||||||
const wcstring &search_string) {
|
const wcstring &search_string) {
|
||||||
// Use a small page size because we don't always offer practical ways to select a item from
|
// Limit the number of elements to half the screen like we do for completions
|
||||||
// a large page (since we don't support subsequence filtering here).
|
// Note that this is imperfect because we could have a multi-column layout.
|
||||||
constexpr size_t page_size = 12;
|
//
|
||||||
|
// We can still push fish further upward in case the first entry is multiline,
|
||||||
|
// but that can't really be helped.
|
||||||
|
// (subtract 2 for the search line and the prompt)
|
||||||
|
size_t page_size = std::max(termsize_last().height / 2 - 2, 12);
|
||||||
|
|
||||||
completion_list_t completions;
|
completion_list_t completions;
|
||||||
history_search_t search{history, search_string, history_search_type_t::contains,
|
history_search_t search{history, search_string, history_search_type_t::contains,
|
||||||
smartcase_flags(search_string), history_index};
|
smartcase_flags(search_string), history_index};
|
||||||
|
|
Loading…
Reference in a new issue