mirror of
https://github.com/tmux/tmux.git
synced 2026-10-09 03:34:25 +00:00
Rebuilding the folded view wrote a linefeed for every source line, including the blank lines at the end, so shrinking the window scrolled the collapsed output into history. Stop at the last non-blank line and rebuild a folded view at the new size when the window is resized. When no cursor position could be restored, the fallback used the source row, which can be past the bottom of the shorter folded view and was then used to index the grid. Fall back to the nearest visible line and clamp to the screen. Keep the unfolded source only while fold view is on, so plain copy mode is back to the incremental sync with one copy of the history. Document toggle-output -m, and rename struct input_osc_133_ctx to struct osc133_marker. Line numbers started with L stay absolute when fold view is toggled. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
108 lines
4.1 KiB
Bash
108 lines
4.1 KiB
Bash
#!/bin/sh
|
|
|
|
PATH=/bin:/usr/bin
|
|
TERM=screen
|
|
|
|
[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux)
|
|
TMUX="$TEST_TMUX -LtestA$$ -f/dev/null"
|
|
|
|
$TMUX kill-server 2>/dev/null
|
|
$TMUX new-session -d -x80 -y20 "sh -c 'printf \"\\033]133;A\\007p\\$ \\033]133;B\\007echo hi\\n\\033]133;C\\007hello\\n\\033]133;D;0\\007separator\\n\\033]133;A\\007p\\$ \\033]133;B\\007\"; exec sleep 100'" || exit 1
|
|
sleep 1
|
|
|
|
$TMUX copy-mode -c || exit 1
|
|
$TMUX send-keys -X search-backward hello || exit 1
|
|
hidden=$($TMUX display-message -p '#{copy_cursor_line}')
|
|
[ "$hidden" != hello ] || exit 1
|
|
$TMUX send-keys -X search-backward separator || exit 1
|
|
hidden=$($TMUX display-message -p '#{copy_cursor_line}')
|
|
[ "$hidden" != separator ] || exit 1
|
|
|
|
$TMUX send-keys BTab || exit 1
|
|
$TMUX send-keys -X search-backward hello || exit 1
|
|
shown=$($TMUX display-message -p '#{copy_cursor_line}')
|
|
[ "$shown" = hello ] || exit 1
|
|
$TMUX send-keys -X select-line || exit 1
|
|
$TMUX send-keys -X copy-selection || exit 1
|
|
selected=$($TMUX show-buffer)
|
|
[ "$selected" = hello ] || exit 1
|
|
$TMUX send-keys -X cancel || exit 1
|
|
|
|
$TMUX kill-server
|
|
$TMUX new-session -d -x80 -y20 "sh -c 'printf \"first\\n\\033]133;D;0\\007separator\\n\\033]133;A\\007p\\$ \\033]133;B\\007\"; exec sleep 100'" || exit 1
|
|
sleep 1
|
|
|
|
$TMUX copy-mode -c || exit 1
|
|
$TMUX send-keys -X search-backward separator || exit 1
|
|
hidden=$($TMUX display-message -p '#{copy_cursor_line}')
|
|
[ "$hidden" != separator ] || exit 1
|
|
$TMUX send-keys BTab || exit 1
|
|
$TMUX send-keys -X search-backward separator || exit 1
|
|
shown=$($TMUX display-message -p '#{copy_cursor_line}')
|
|
[ "$shown" = separator ] || exit 1
|
|
$TMUX send-keys -X cancel || exit 1
|
|
|
|
$TMUX kill-server
|
|
$TMUX new-session -d -x80 -y20 "sh -c 'printf \"\\033]133;A\\007P> \\033]133;B\\007for i in 1 2 3; do\\n\\033]133;A;k=s\\007> \\033]133;B\\007echo \\\$i\\n\\033]133;P;k=s\\007> \\033]133;B\\007done\\n\\033]133;C\\007RESULT\\n\\033]133;D;0\\007separator\\n\\033]133;A\\007P> \\033]133;B\\007\"; exec sleep 100'" || exit 1
|
|
sleep 1
|
|
|
|
$TMUX copy-mode -c || exit 1
|
|
$TMUX send-keys -X search-backward RESULT || exit 1
|
|
hidden=$($TMUX display-message -p '#{copy_cursor_line}')
|
|
[ "$hidden" != RESULT ] || exit 1
|
|
$TMUX send-keys -X search-backward-text 'echo $i' || exit 1
|
|
shown=$($TMUX display-message -p '#{copy_cursor_line}')
|
|
[ "$shown" = '> echo $i' ] || exit 1
|
|
$TMUX send-keys -X cancel || exit 1
|
|
|
|
$TMUX copy-mode -U || exit 1
|
|
$TMUX send-keys -X search-backward RESULT || exit 1
|
|
$TMUX send-keys Tab || exit 1
|
|
cursor=$($TMUX display-message -p '#{copy_cursor_line}')
|
|
[ "$cursor" = '> done' ] || exit 1
|
|
$TMUX send-keys -X cancel || exit 1
|
|
|
|
$TMUX kill-server
|
|
$TMUX new-session -d -x80 -y20 "sh -c 'printf \"\\033]133;A\\007P0> \\033]133;B\\007\\r\\n\\033]133;D;0\\007empty-separator\\n\\033]133;A\\007P1> \\033]133;B\\007\"; exec sleep 100'" || exit 1
|
|
sleep 1
|
|
|
|
$TMUX copy-mode -c || exit 1
|
|
collapsed=$($TMUX capture-pane -Mp)
|
|
case "$collapsed" in
|
|
*empty-separator*) exit 1 ;;
|
|
*P0\>*P1\>*) ;;
|
|
*) exit 1 ;;
|
|
esac
|
|
cursor=$($TMUX display-message -p '#{copy_cursor_line}')
|
|
[ "$cursor" = 'P1>' ] || exit 1
|
|
$TMUX send-keys -X search-backward empty-separator || exit 1
|
|
hidden=$($TMUX display-message -p '#{copy_cursor_line}')
|
|
[ "$hidden" != empty-separator ] || exit 1
|
|
$TMUX send-keys -X cancel || exit 1
|
|
|
|
# Shrinking the window must keep the collapsed lines in view.
|
|
$TMUX copy-mode -c || exit 1
|
|
$TMUX resize-window -y8 || exit 1
|
|
sleep 1
|
|
resized=$($TMUX capture-pane -Mp)
|
|
case "$resized" in
|
|
*P0\>*P1\>*) ;;
|
|
*) exit 1 ;;
|
|
esac
|
|
cursor=$($TMUX display-message -p '#{copy_cursor_line}')
|
|
[ "$cursor" = 'P1>' ] || exit 1
|
|
$TMUX send-keys -X cancel || exit 1
|
|
|
|
# The cursor must stay on the screen when it is below the folded output.
|
|
$TMUX kill-server
|
|
$TMUX new-session -d -x80 -y12 "sh -c 'i=0; while [ \$i -lt 3 ]; do printf \"\\033]133;A\\007p\\$ \\033]133;B\\007cmd\\r\\n\\033]133;C\\007one\\r\\ntwo\\r\\nthree\\r\\nfour\\r\\n\\033]133;D;0\\007\"; i=\$((i + 1)); done; printf \"\\033]133;A\\007p\\$ \"; j=0; while [ \$j -lt 8 ]; do printf \"live\\r\\n\"; j=\$((j + 1)); done; exec sleep 100'" || exit 1
|
|
sleep 1
|
|
|
|
$TMUX copy-mode -c || exit 1
|
|
cursor=$($TMUX display-message -p '#{copy_cursor_y}')
|
|
[ "$cursor" -lt 12 ] || exit 1
|
|
$TMUX send-keys -X cancel || exit 1
|
|
|
|
$TMUX kill-server 2>/dev/null
|
|
exit 0
|