From 2a065a653531a6201d283712a62c8bbca919dbd5 Mon Sep 17 00:00:00 2001 From: Daniel Vu Date: Sun, 5 Jul 2026 22:08:40 -0400 Subject: [PATCH] perf(region): don't force a full repaint on idle/no-op redisplays The active-region WFFULL escalation ran before the 'nothing to redisplay' early-out, so every update() cycle re-rendered the whole window while a region was active -- even no-op keys that moved nothing. Move it after the w_rflag==0 continue: only escalate a redraw that's already needed. Correctness is unchanged (a real move sets w_rflag, so the region still repaints and tracks point), and selecting-case bytes are identical (uline already diffs cells and emits only the changed boundary rows -- the region repaint was never sending the whole window). macOS 331/331, TSan clean, c-legacy clean. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01Pj1ZHaD7aNhVWJ69SFKJcp --- src/display.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/display.c b/src/display.c index bca494ac..b480a131 100644 --- a/src/display.c +++ b/src/display.c @@ -678,18 +678,24 @@ update(int modelinecolor) } hflag = FALSE; /* Not hard. */ for (wp = wheadp; wp != NULL; wp = wp->w_wndp) { -#ifdef ENABLE_NATIVE_MAGIT - /* The current window's active region repaints fully so the - * standout tracks point (only curwp's region is drawn). */ - if (wp == curwp && (wp->w_flag & WMARKED)) - wp->w_rflag |= WFFULL; -#endif /* * Nothing to be done. */ if (wp->w_rflag == 0) continue; #ifdef ENABLE_NATIVE_MAGIT + /* + * The current window's active region must repaint enough of the + * window to move the standout with point, so escalate a redraw + * that is ALREADY needed to a full one. Doing this only when the + * window already has redisplay flags set means an idle cycle + * (e.g. a background magit refresh) or a no-op key leaves the + * region as-is instead of re-rendering every row for nothing. + * (uline diffs cells, so a genuine move still emits only the + * boundary rows whose highlight actually changed.) + */ + if (wp == curwp && (wp->w_flag & WMARKED)) + wp->w_rflag |= WFFULL; region_hl_setup(wp); /* order the mark/point span for this window */ #endif