From 120285c478b9b4ef33191cb24f8d5b6ad48e818f Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Fri, 5 Jul 2024 14:19:56 +0200 Subject: [PATCH] tmux:textobjs: Do not use scroll_region scroll_region_{upper,lower} are only modified by the DECSTBM escape sequence: > This control function sets the top and bottom margins for the current > page. You cannot perform scrolling outside the margins. And are 0 and pane_height - 1 otherwise. Tmux implements these such that command output can't be displayed outside these margins, but the cursor in copy-mode can. This means that using them to check if the cursor is at the very top or bottom can break in certain situation (even those seem extremely rare since I have never heard of this escape sequence). Get rid of them and just use 0 and the pane height. [1]: https://vt100.net/docs/vt510-rm/DECSTBM.html --- .config/tmux/textobjs.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.config/tmux/textobjs.sh b/.config/tmux/textobjs.sh index 05d8eef..a4c19c2 100755 --- a/.config/tmux/textobjs.sh +++ b/.config/tmux/textobjs.sh @@ -48,10 +48,8 @@ case "$motion" in scroll_pos="$(get_var scroll_position)" hist_size="$(get_var history_size)" cursor_y="$(get_var copy_cursor_y)" - scroll_upper="$(get_var scroll_region_upper)" # don't move down if we're at the very first paragraph - if [ "$scroll_pos" -lt "$hist_size" ] \ - || [ "$cursor_y" -gt "$scroll_upper" ] + if [ "$scroll_pos" -lt "$hist_size" ] || [ "$cursor_y" -gt 0 ] then tmux send -X cursor-down fi @@ -62,9 +60,11 @@ case "$motion" in scroll_pos="$(get_var scroll_position)" cursor_y="$(get_var copy_cursor_y)" - scroll_lower="$(get_var scroll_region_lower)" + pane_height="$(get_var pane_height)" + : "$((pane_height -= 1))" # don't move up if we're at the very last paragraph - if [ "$scroll_pos" -gt 0 ] || [ "$cursor_y" -lt "$scroll_lower" ]; then + if [ "$scroll_pos" -gt 0 ] || [ "$cursor_y" -lt "$pane_height" ] + then tmux send -X cursor-up fi