From 374b01242df33448a7e56a5b360006e983946aee Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Thu, 16 Jul 2026 23:19:15 +0900 Subject: [PATCH] Wrap frames in synchronized update mode (2026) Reduce flickering during rendering on supported terminals. --- src/tui/light.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/tui/light.go b/src/tui/light.go index 42f9b272..0ac445a9 100644 --- a/src/tui/light.go +++ b/src/tui/light.go @@ -92,12 +92,14 @@ func (r *LightRenderer) csi(code string) string { func (r *LightRenderer) flush() { if r.queued.Len() > 0 { - raw := "\x1b[?7l\x1b[?25l" + r.queued.String() + // Wrap the frame in synchronized update mode (2026) so that the + // terminal applies it atomically. Terminals without support ignore + // the unknown private mode and behave as before. + raw := "\x1b[?2026h\x1b[?7l\x1b[?25l" + r.queued.String() if r.showCursor { - raw += "\x1b[?25h\x1b[?7h" - } else { - raw += "\x1b[?7h" + raw += "\x1b[?25h" } + raw += "\x1b[?7h\x1b[?2026l" r.flushRaw(raw) r.queued.Reset() }