From cda0fe9f7ba3f6e66098f336276817d9c1104f60 Mon Sep 17 00:00:00 2001 From: Michael Grant Date: Mon, 7 Sep 2026 05:21:25 +0100 Subject: [PATCH] Act on previous cmd output when cursor on prompt at end of copy-buffer. --- regress/output-commands.sh | 7 +++++++ window-copy.c | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/regress/output-commands.sh b/regress/output-commands.sh index 2a0af404e..03ba9fee2 100644 --- a/regress/output-commands.sh +++ b/regress/output-commands.sh @@ -99,6 +99,13 @@ sleep 1 $TMUX copy-output -t :empty || exit 1 [ "$($TMUX show-buffer)" = one ] || exit 1 +$TMUX new-window -d -n prompt "printf '\\033]133;A\\007p\\$ \\033]133;B\\007echo\\033]133;C\\007one\\n\\033]133;D;0\\007\\033]133;A\\007p\\$ \\033]133;B\\007'; exec sleep 100" || exit 1 +sleep 1 +$TMUX copy-mode -U -t :prompt || exit 1 +$TMUX send-keys -t :prompt.0 -X copy-output || exit 1 +[ "$($TMUX show-buffer)" = one ] || exit 1 +$TMUX send-keys -t :prompt.0 -X cancel || exit 1 + $TMUX copy-mode -t :plain || exit 1 $TMUX send-keys -t :plain.0 -X copy-output -a || exit 1 all=$($TMUX show-buffer) diff --git a/window-copy.c b/window-copy.c index 091314b4b..d2ea09396 100644 --- a/window-copy.c +++ b/window-copy.c @@ -4182,8 +4182,13 @@ window_copy_find_output_range(struct window_mode_entry *wme, u_int *sx, break; } } - if (!found_start) + if (!found_start) { + /* At the live prompt, use the most recent command output. */ + if (cursor_y == screen_hsize(data->source) + data->source->cy) + return (window_copy_find_previous_output_range(data->source, + sx, sy, ex, ey)); return (0); + } if (!found_end) { if (y != total) return (0);