Preserve the copy-mode entry column after trailing blanks

This commit is contained in:
Michael Grant
2026-10-05 16:55:22 +01:00
parent a1825146ee
commit 6137fd04e9
2 changed files with 73 additions and 23 deletions

View File

@@ -137,6 +137,51 @@ x cursor-up
check_cursor 7,0
x cancel
# Trailing blanks must not replace the initial preference on the first move.
for entry_line in 'prompt> ' ' '; do
$TMUX respawn-pane -k \
"printf '\033[H\033[2J'; \
printf '%s\r\n' ABCDEFGHIJKLMNOPQRST abc ABCDEFGHIJKLMNOPQRST \
'$entry_line' ABCDEFGHIJKLMNOP ab 01234567890123456789; \
printf '\033[4;9H'; exec cat" || fail "respawn-pane failed"
wait_cursor 8,3
for mode in emacs vi; do
$TMUX set-window-option -g mode-keys "$mode" ||
fail "set mode-keys failed"
for direction in up down; do
if [ "$direction" = up ]; then
row=2
end=20
short=3
last=0
else
row=4
end=16
short=2
last=6
fi
[ "$mode" = emacs ] || end=$((end - 1))
$TMUX copy-mode || fail "copy-mode failed"
x "cursor-$direction"
check_cursor "$end,$row"
x cancel
$TMUX copy-mode -c || fail "copy-mode -c failed"
check_cursor 8,3
x "cursor-$direction"
check_cursor "8,$row"
x "cursor-$direction"
x "cursor-$direction"
if [ "$mode" = emacs ]; then
check_cursor "8,$last"
else
check_cursor "$((short - 1)),$last"
fi
x cancel
done
done
done
# An empty entry line has a numeric column zero with -c.
$TMUX respawn-pane -k \
"printf '\033[H\033[2JABCDEFGHIJKLMNOPQRST\033[2;1H'; exec cat" ||
@@ -172,7 +217,7 @@ done
# Initialize before the optional entry-time page movement.
$TMUX respawn-pane -k \
"printf '\033[H\033[2JABCDEFGHIJKLMNOPQRST'; \
printf '\033[9;1Habcdefgh\033[10;1HABCDEFGHIJKLMNOP\033[9;9H'; \
printf '\033[9;1Hprompt> \033[10;1HABCDEFGHIJKLMNOP\033[9;9H'; \
exec cat" ||
fail "respawn-pane failed"
wait_cursor 8,8