Skip to content

perf(region): skip full repaint on idle/no-op redisplays - #119

Merged
danielxvu merged 1 commit into
neomgfrom
fm-region-repaint-idle
Jul 6, 2026
Merged

perf(region): skip full repaint on idle/no-op redisplays#119
danielxvu merged 1 commit into
neomgfrom
fm-region-repaint-idle

Conversation

@danielxvu

Copy link
Copy Markdown
Owner

While investigating region-highlight latency, confirmed mg's uline already diffs at the cell level — so the active-region repaint was never sending the whole window; the extra bytes on a move are the inherent cost of the highlight shifting across ~2 boundary rows.

The one real waste: the WFFULL escalation ran before the w_rflag == 0 early-out, so every update() re-rendered all rows while a region was active, even for no-op keys. Moved it after the early-out — only escalate a redraw that is already needed. Correctness unchanged (a genuine move sets w_rflag, region still tracks point); selecting-case bytes identical (15 B plain / 153 B region, before and after).

macOS 331/331 · TSan zero races · Alpine/musl 331/331 · legacy plain-C clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Pj1ZHaD7aNhVWJ69SFKJcp

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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pj1ZHaD7aNhVWJ69SFKJcp
@danielxvu
danielxvu merged commit 336541d into neomg Jul 6, 2026
14 of 16 checks passed
@danielxvu
danielxvu deleted the fm-region-repaint-idle branch July 6, 2026 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant