From b2de803871e579565a6f79296f386115142593ed Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 17 Aug 2026 20:04:00 +0000 Subject: [PATCH] Flush output before ending sync. GitHub issue 5495 from xiangzhedev at gmail dot com. --- input.c | 4 ++-- screen-write.c | 15 ++++++++++++++- tmux.h | 3 ++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/input.c b/input.c index ecf07dd61..5f9c5f4ab 100644 --- a/input.c +++ b/input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: input.c,v 1.269 2026/07/20 11:16:33 nicm Exp $ */ +/* $OpenBSD: input.c,v 1.270 2026/08/17 20:04:00 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -1974,7 +1974,7 @@ input_csi_dispatch_rm_private(struct input_ctx *ictx) screen_write_mode_clear(sctx, MODE_BRACKETPASTE); break; case 2026: - screen_write_stop_sync(ictx->wp); + screen_write_end_sync(sctx); break; case 2031: screen_write_mode_clear(sctx, MODE_THEME_UPDATES); diff --git a/screen-write.c b/screen-write.c index 71dc99200..990ef4e0f 100644 --- a/screen-write.c +++ b/screen-write.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen-write.c,v 1.286 2026/08/03 12:58:53 nicm Exp $ */ +/* $OpenBSD: screen-write.c,v 1.287 2026/08/17 20:04:00 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -1059,6 +1059,19 @@ screen_write_stop_sync(struct window_pane *wp) log_debug("%s: %%%u stopped sync mode", __func__, wp->id); } +/* Flush pending output before clearing sync mode. */ +void +screen_write_end_sync(struct screen_write_ctx *ctx) +{ + struct window_pane *wp = ctx->wp; + + if (wp == NULL) + return; + if (wp->base.mode & MODE_SYNC) + screen_write_collect_flush(ctx, 0, __func__); + screen_write_stop_sync(wp); +} + /* Cursor up by ny. */ void screen_write_cursorup(struct screen_write_ctx *ctx, u_int ny) diff --git a/tmux.h b/tmux.h index 6cd104b50..11d9e3d4d 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.1424 2026/08/17 14:47:41 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.1425 2026/08/17 20:04:00 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -3554,6 +3554,7 @@ void screen_write_mode_set(struct screen_write_ctx *, int); void screen_write_mode_clear(struct screen_write_ctx *, int); void screen_write_start_sync(struct window_pane *); void screen_write_stop_sync(struct window_pane *); +void screen_write_end_sync(struct screen_write_ctx *); void screen_write_clear_dirty(struct window_pane *); void screen_write_cursorup(struct screen_write_ctx *, u_int); void screen_write_cursordown(struct screen_write_ctx *, u_int);