From b90bab875ca8cf125040b7c3b894babd337ec2e7 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 13 Feb 2025 23:20:31 -0800 Subject: basta.fullscreen_alt: fix off-by-one bug in scroll logic. * basta.sh (basta.fullscreen_alt): The worst case number of scrolls needed is basta_prev_reserved_rows + 1, the height of the status area, not not basta_prev_reserved_rows. Now the [ $scrolls_needed -ge 0 ] test is correct, and we don't we don't need the extra newline in the final printf. The behavior is now good in the cases when the command prints zero, one, two, and three lines. --- basta.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basta.sh b/basta.sh index bf999c8..d0afc20 100644 --- a/basta.sh +++ b/basta.sh @@ -354,7 +354,7 @@ basta.fullscreen_alt() { basta_deferred_intr=WINCH LINES=$realrows command "$@" || exit=$? - local scrolls_needed=$basta_prev_reserved_rows + local scrolls_needed=$((basta_prev_reserved_rows + 1)) if basta.query_terminal_lines realrows >&$ttyfd <&$ttyfd && basta.get_cur_line curline >&$ttyfd <&$ttyfd @@ -369,7 +369,7 @@ basta.fullscreen_alt() { printf $'\n' >&$ttyfd done - printf $'\n\e[%sA' $(( basta_prev_reserved_rows + 1 )) >&$ttyfd + printf $'\e[%sA' $(( basta_prev_reserved_rows + 1 )) >&$ttyfd fi exec {ttyfd}>&- -- cgit v1.2.3