Skip to content

Fix flickering when exiting copy mode#270

Merged
dakra merged 1 commit into
dakra:mainfrom
mgeisler:fix-redraw-flicker
May 13, 2026
Merged

Fix flickering when exiting copy mode#270
dakra merged 1 commit into
dakra:mainfrom
mgeisler:fix-redraw-flicker

Conversation

@mgeisler
Copy link
Copy Markdown
Contributor

When exiting read-only modes (like copy mode or Emacs mode), the viewport is snapped back to the live terminal cursor, which involves jumping point to the end of the buffer. Previously, this process scheduled an asynchronous delayed redraw.

During the delay before the timer fired, control returned to the Emacs redisplay engine. Emacs would observe point at point-max and attempt to violently recenter the window around it. Once the ghostel--delayed-redraw timer finally fired a few milliseconds later, it would calculate the true active area (the viewport-start) and anchor the window back into place, resulting in a visible and jarring flicker.

This commit adds a synchronous call to ghostel-force-redraw at the end of the read-only exit sequence. By forcing the redraw immediately, the window is correctly anchored to the terminal's active viewport before Emacs has a chance to perform an unanchored redisplay cycle.

Fixes #269.

When exiting read-only modes (like copy mode or Emacs mode), the viewport is
snapped back to the live terminal cursor, which involves jumping point to the
end of the buffer. Previously, this process scheduled an asynchronous delayed
redraw.

During the delay before the timer fired, control returned to the Emacs
redisplay engine. Emacs would observe point at `point-max` and attempt to
violently recenter the window around it. Once the `ghostel--delayed-redraw`
timer finally fired a few milliseconds later, it would calculate the true
active area (the `viewport-start`) and anchor the window back into place,
resulting in a visible and jarring flicker.

This commit adds a synchronous call to `ghostel-force-redraw` at the end of
the read-only exit sequence. By forcing the redraw immediately, the window
is correctly anchored to the terminal's active viewport before Emacs has a
chance to perform an unanchored redisplay cycle.

Fixes dakra#269.
@dakra dakra force-pushed the fix-redraw-flicker branch from 8f65af4 to ae2fddb Compare May 13, 2026 07:44
@dakra dakra merged commit ae2fddb into dakra:main May 13, 2026
16 checks passed
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.

Flickering when exiting copy mode

2 participants