From 6ec0cfbaba2f2d25a4acc997e83bccf740ccc7f4 Mon Sep 17 00:00:00 2001 From: Isaac Oscar Gariano Date: Mon, 6 Jul 2026 13:56:49 +1000 Subject: [PATCH] Allow filepanes to work on small terminal sizes (fixes tilde #104) --- src/widgets/filepane.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/widgets/filepane.cc b/src/widgets/filepane.cc index e191466..1017702 100644 --- a/src/widgets/filepane.cc +++ b/src/widgets/filepane.cc @@ -106,7 +106,7 @@ void file_pane_t::ensure_cursor_on_screen() { height = window.get_height() - 1; - while (impl->current >= impl->top_idx + impl->columns_visible * height) { + while (height != 0 && impl->current >= impl->top_idx + impl->columns_visible * height) { impl->top_idx += height; } while (impl->current < impl->top_idx && impl->top_idx > static_cast(height)) { @@ -229,7 +229,7 @@ bool file_pane_t::set_size(optint height, optint width) { height = height.value() - 1; if (impl->file_list != nullptr && impl->file_list->size() != 0) { update_column_widths(); - impl->scrollbar_range = + impl->scrollbar_range = height.value() == 0 ? 0 : ((impl->file_list->size() + height.value() - 1) / height.value()) * height.value(); ensure_cursor_on_screen(); } @@ -444,7 +444,7 @@ void file_pane_t::content_changed() { impl->top_idx = 0; update_column_widths(); - impl->scrollbar_range = ((impl->file_list->size() + height - 1) / height) * height; + impl->scrollbar_range = height == 0 ? 0 : ((impl->file_list->size() + height - 1) / height) * height; force_redraw(); }