mirror of
https://github.com/tmux/tmux.git
synced 2026-10-11 13:04:22 +00:00
Prepare collapsible OSC 133 output for review
Use the parent output-range implementation and preserve source rows and columns when output is folded or wrapped. Clear stale exit-status presence on repeated D markers. Apply the requested coding style and add regressions for folded output selections and prompt properties.
This commit is contained in:
64
regress/collapse-output-copy.sh
Normal file
64
regress/collapse-output-copy.sh
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/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
|
||||
trap '$TMUX kill-server 2>/dev/null' 0
|
||||
trap 'exit 1' 1 2 3 15
|
||||
|
||||
$TMUX new-session -d -x20 -y10 \
|
||||
"printf '\033]133;A\007P0> \033]133;B\007first\r\n\033]133;C\007FIRST-OUTPUT\r\n\033]133;D;0\007\033]133;A\007P1> \033]133;B\007second\r\n\033]133;C\007012345678901234567890123456789\r\nlast\r\n\033]133;D;7\007\033]133;A\007P2> \033]133;B\007'; exec sleep 100" || exit 1
|
||||
sleep 1
|
||||
|
||||
expected=$(printf '012345678901234567890123456789\nlast')
|
||||
for keys in emacs vi; do
|
||||
$TMUX set -g mode-keys "$keys" || exit 1
|
||||
$TMUX copy-mode -c || exit 1
|
||||
$TMUX send -X search-backward-text second || exit 1
|
||||
$TMUX set-buffer sentinel || exit 1
|
||||
$TMUX send -X copy-output || exit 1
|
||||
[ "$($TMUX show-buffer)" = "$expected" ] || exit 1
|
||||
|
||||
$TMUX send -X select-output || exit 1
|
||||
[ "$($TMUX display -p '#{selection_present}')" = 1 ] || exit 1
|
||||
$TMUX send -X copy-selection || exit 1
|
||||
[ "$($TMUX show-buffer)" = "$expected" ] || exit 1
|
||||
case "$($TMUX capture-pane -Mp)" in
|
||||
*FIRST-OUTPUT*) exit 1 ;;
|
||||
esac
|
||||
|
||||
# All-output commands include the original source, even while folded.
|
||||
$TMUX send -X copy-output -a || exit 1
|
||||
all=$($TMUX show-buffer)
|
||||
case "$all" in
|
||||
*FIRST-OUTPUT*012345678901234567890123456789*last*) ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
$TMUX send -X select-output -a || exit 1
|
||||
$TMUX send -X copy-selection || exit 1
|
||||
[ "$($TMUX show-buffer)" = "$all" ] || exit 1
|
||||
$TMUX send -X cancel || exit 1
|
||||
done
|
||||
|
||||
# A prompt after an output end on the same source line moves left when folded.
|
||||
$TMUX new-window -n shared \
|
||||
"printf '\033]133;A\007P0> \033]133;B\007first\r\n\033]133;C\007head\r\ntail\033]133;D;0\007\033]133;A\007P1> \033]133;B\007second\r\n\033]133;C\007SECOND-OUTPUT\r\n\033]133;D;0\007\033]133;A\007P2> \033]133;B\007'; exec sleep 100" || exit 1
|
||||
sleep 1
|
||||
for keys in emacs vi; do
|
||||
$TMUX set -g mode-keys "$keys" || exit 1
|
||||
$TMUX copy-mode -c || exit 1
|
||||
$TMUX send -X search-backward-text P1 || exit 1
|
||||
$TMUX send -X start-of-line || exit 1
|
||||
$TMUX send -X copy-output || exit 1
|
||||
[ "$($TMUX show-buffer)" = SECOND-OUTPUT ] || exit 1
|
||||
$TMUX send -X select-output || exit 1
|
||||
$TMUX send -X copy-selection || exit 1
|
||||
[ "$($TMUX show-buffer)" = SECOND-OUTPUT ] || exit 1
|
||||
$TMUX send -X cancel || exit 1
|
||||
done
|
||||
|
||||
exit 0
|
||||
@@ -37,5 +37,20 @@ check_raw_matches osc133-status \
|
||||
'L 4 \(4\) flags=START_OUTPUT,END_OUTPUT\[[0-9a-f]+\].* osc133=0,0,0,1,0' \
|
||||
'L 5 \(5\) flags=START_OUTPUT,END_OUTPUT\[[0-9a-f]+\].* osc133=0,0,0,1,0'
|
||||
|
||||
# A later D without a status must clear the earlier status-present flag.
|
||||
start_pane osc133-repeated-status 20 3 \
|
||||
'\033]133;C\007out\033]133;D;7\007\033]133;D\007\n'
|
||||
check_raw_matches osc133-repeated-status \
|
||||
'L 0 \(0\) flags=START_OUTPUT,END_OUTPUT\[[0-9a-f]+\].* osc133=0,0,0,3,0'
|
||||
|
||||
# Prompt properties may repeat or appear in any order; values must end.
|
||||
start_pane osc133-properties 20 6 \
|
||||
'\033]133;A;foo=bar;k=s;id=1\007secondary\n\033]133;P;k=x;foo=bar;k=c\007continuation\n\033]133;A;k=second\007primary\n\033]133;P;k=continued\007primary\n'
|
||||
check_raw_matches osc133-properties \
|
||||
'L 0 \(0\) flags=SECOND_PROMPT\[[0-9a-f]+\].* osc133=0,0,0,0,0' \
|
||||
'L 1 \(1\) flags=SECOND_PROMPT\[[0-9a-f]+\].* osc133=0,0,0,0,0' \
|
||||
'L 2 \(2\) flags=START_PROMPT\[[0-9a-f]+\].* osc133=0,0,0,0,0' \
|
||||
'L 3 \(3\) flags=START_PROMPT\[[0-9a-f]+\].* osc133=0,0,0,0,0'
|
||||
|
||||
$TMUX kill-server 2>/dev/null
|
||||
exit $exit_status
|
||||
|
||||
Reference in New Issue
Block a user