Fix collapsed copy mode on resize and with the cursor below the output.

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>
This commit is contained in:
Michael Grant
2026-10-08 21:05:05 +02:00
parent 0d65a0f60c
commit b4810e5b2d
6 changed files with 243 additions and 174 deletions

6
tmux.h
View File

@@ -917,7 +917,7 @@ struct osc133_data {
};
/* Saved OSC 133 output marker. */
struct input_osc_133_ctx {
struct osc133_marker {
int running;
u_int start;
u_int col;
@@ -3457,10 +3457,10 @@ void input_reply_clipboard(struct bufferevent *, const char *, size_t,
void input_set_buffer_size(size_t);
void input_request_reply(struct client *, enum input_request_type, void *);
void input_cancel_requests(struct client *);
struct input_osc_133_ctx input_osc_133_save_marker(struct window_pane *,
struct osc133_marker input_osc_133_save_marker(struct window_pane *,
struct screen *);
void input_osc_133_restore_marker(struct screen *,
const struct input_osc_133_ctx *);
const struct osc133_marker *);
/* input-key.c */
void input_key_build(void);