Files
tmux/regress/image-status-pane-click-noflash.sh
Michael Grant 21948cd117 regress: rationalise image test coverage, add missing image_support guard
- Extract shared setup for the "noflash" retransmission-avoidance tests
  (image-movepane-drag-noflash.sh, image-splitwindow-resize-noflash.sh,
  image-status-pane-click-noflash.sh, image-selection-noflash.sh) into
  a new image-noflash-common.inc, matching the existing input-common.inc
  convention: dual-server cleanup/fail helpers, the shared SIXEL fixture,
  the attach-and-capture sequence, and the final DCS-retransmission
  assertion. Each test keeps its own distinct interaction and failure
  message; only the copy-pasted scaffolding moved.

- Add the missing #{image_support} runtime guard to
  image-border-status-sixel.sh, which cats a real SIXEL fixture and
  specifically guards a sixel-after-pane-creation ordering bug - without
  it, the DCS sequence is compiled out entirely on a non-image build and
  the test's assertions could pass without exercising anything.
  image-border-status-wipe.sh is deliberately left unguarded: it has no
  image/sixel content at all and guards a general border-status caching
  bug unrelated to ENABLE_IMAGES.

- Reviewed the rest of the branch's regress/image-*.sh tests in full
  (not just headers) for redundant coverage; none warranted merging -
  each guards a genuinely distinct fix via a distinct mechanism.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-09 23:10:15 +02:00

72 lines
3.0 KiB
Bash
Executable File

#!/bin/sh
# Regression test: clicking a pane's name in a second (#{P:}) status line to
# make it active must not retransmit images in other panes of the same
# window.
#
# The default MouseDown1Status binding is "switch-client -t=". When status
# is set to 2 or more, the second status line's default format lists each
# pane individually with a "pane" mouse range, so clicking a pane name there
# resolves that binding's target to a specific pane rather than a session or
# window - but switch-client still runs through server_client_set_session()
# (server-client.c), which used to call server_redraw_client() (forcing a
# full CLIENT_REDRAWWINDOW pass, wiping and retransmitting every image in
# the window) unconditionally, even though neither the client's session nor
# its current window actually changed - only the active pane within the
# already-current window did, which window_set_active_pane() and
# window_redraw_active_switch() already handle narrowly on their own.
#
# This is checked by counting DCS (\033P) sequences in the client's raw
# output while an inactive pane's own image (never touched by the click) is
# present: with the fix, none should appear.
. ./image-noflash-common.inc
# A distinctive SIXEL raster in the left (initially active) pane, and a
# second, plain pane to its right. Two status lines are enabled, so the
# second status line lists both panes individually and clicking a pane's
# name there is possible.
$TMUX new-session -d -s inner -x 60 -y 12 "printf '$SIXEL_HEADER'; exec sh" ||
exit 1
$TMUX set -g mouse on || fail "set mouse failed"
$TMUX set -g status 2 || fail "set status failed"
$TMUX split-window -h -t inner 'exec sh' || fail "split-window failed"
$TMUX select-pane -t inner.0 || fail "select-pane failed"
sleep 0.3
[ "$($TMUX display-message -p '#{image_support}')" = 0 ] && exit 0
$TMUX set -as terminal-features ',*:sixel' || exit 1
start_capture 60 12
# Sanity check: the image reaches the client, and pane 0 (holding it) is
# active.
assert_image_reached
[ "$($TMUX display-message -p -t inner.0 '#{pane_active}')" = 1 ] ||
fail "sanity: pane 0 not active before the click"
: >$TMP
# Locate pane 1's clickable entry in the second (bottom) status line - the
# default window-pane-status-format starts with the pane index, so its
# entry is identifiable by the literal text "1:[".
STATUSLINE=$($TMUX2 capture-pane -p -t "$OUTER" | tail -1)
COL=$(echo "$STATUSLINE" | awk '{print index($0, "1:[")}')
[ "$COL" -gt 0 ] || fail "sanity: could not find pane 1's status entry"
ROW=12
# Click pane 1's name in the second status line - this should make pane 1
# active without disturbing pane 0's already-displayed image.
seq=$(printf '\033[<0;%s;%sM' "$COL" "$ROW")
$TMUX2 send-keys -t "$OUTER" -l "$seq" 2>/dev/null
sleep 0.2
seq=$(printf '\033[<0;%s;%sm' "$COL" "$ROW")
$TMUX2 send-keys -t "$OUTER" -l "$seq" 2>/dev/null
sleep 1
[ "$($TMUX display-message -p -t inner.1 '#{pane_active}')" = 1 ] ||
fail "click did not make pane 1 active"
assert_no_retransmit "after clicking another pane's status entry"
exit 0