From 551294994730c106d29ce9614881e04f8515f437 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 7 Oct 2026 14:14:02 +0100 Subject: [PATCH] Test for 5696. --- regress/switch-mode.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/regress/switch-mode.sh b/regress/switch-mode.sh index 5f3fe8c12..bfb87dc2b 100644 --- a/regress/switch-mode.sh +++ b/regress/switch-mode.sh @@ -63,6 +63,22 @@ wait_count() fail "found $count '$marker' rows, expected $want" } +wait_first() +{ + marker=$1 + want=$2 + i=0 + while [ "$i" -lt 50 ]; do + got=$(capture | grep -F "$marker" | head -1) + case "$got" in + "$want"*) return 0 ;; + esac + sleep 0.1 + i=$((i + 1)) + done + fail "first '$marker' row is '$got', expected prefix '$want'" +} + wait_format() { target=$1 @@ -150,6 +166,22 @@ case "$picked" in *) fail "window selection produced '$picked', expected '=bravo:0.'" ;; esac +# -O selects the sort order and -r reverses it. By name the aaa window is +# first, by index main is, and by name reversed pick-two is. +$INNER new-window -d -t alpha: -n aaa 'exec sleep 100' || exit 1 +$INNER switch-mode -w -t alpha:main.0 -F 'ORDER #{window_name}' -O name || exit 1 +wait_first 'ORDER ' 'ORDER aaa' +$INNER send-keys -t alpha:main.0 Escape || exit 1 +wait_format alpha:main.0 '#{pane_in_mode}' 0 +$INNER switch-mode -w -t alpha:main.0 -F 'ORDER #{window_name}' -O index || exit 1 +wait_first 'ORDER ' 'ORDER last' +$INNER send-keys -t alpha:main.0 Escape || exit 1 +wait_format alpha:main.0 '#{pane_in_mode}' 0 +$INNER switch-mode -w -t alpha:main.0 -F 'ORDER #{window_name}' -O name -r || exit 1 +wait_first 'ORDER ' 'ORDER pick-two' +$INNER send-keys -t alpha:main.0 Escape || exit 1 +wait_format alpha:main.0 '#{pane_in_mode}' 0 + # Navigation with an empty result set must be harmless, and Escape cancels # without running the custom command. $INNER set-option -g @picked unchanged || exit 1