Skip to content

Don't repaint the screen when an interrupt is pending - #828

Closed
kerneltoast wants to merge 1 commit into
gwsw:masterfrom
kerneltoast:fix-ctrl-c-repaint
Closed

kerneltoast wants to merge 1 commit into
gwsw:masterfrom
kerneltoast:fix-ctrl-c-repaint

Conversation

@kerneltoast

Copy link
Copy Markdown

With less -FRXK as Git's pager, pressing Ctrl-C during a slow git log search can erase results that haven't filled the first screen yet.

The second repaint in prompt() clears the screen after the signal handler marks it as trashed, but the pending interrupt prevents it from restoring the text. Skip that repaint while an abort signal is pending so the command loop can handle the interrupt first.

To reproduce in a 24-row terminal, run this command and press Ctrl-C when the ten numbers appear:

(seq 1 10; sleep 60) | less -FRXK

Without the fix, the screen is cleared. With the fix, the displayed numbers remain visible after less exits.

This patch and PR description were written by AI.

With less -FRXK as Git's pager, pressing Ctrl-C during a slow git log
search can erase the results already displayed if they haven't filled the
first screen yet.

When Ctrl-C interrupts the initial display of slow pipe input, the signal
handler marks the screen as trashed. The extra repaint added by
429ed1f ("Fix bad display if prompt_message wraps.") clears the
screen, but the pending interrupt prevents it from restoring the text.
With -K, less then exits and the displayed output is lost.

Skip the second repaint while an abort signal is pending to let the
command loop handle the interrupt first.

Assisted-by: LLM
gwsw added a commit that referenced this pull request Sep 27, 2026
There are some cases where we enter forw() or back() with an abort
signal pending. Previously we might clear the position table and
only then notice the signal, and then return without adding any lines.
It's better to return immediately without clearing the position table,
so we retain the screen contents.

Related to #828.
@gwsw

gwsw commented Sep 27, 2026

Copy link
Copy Markdown
Owner

Fixed differently in c1a2f7c.

@kerneltoast

Copy link
Copy Markdown
Author

Thank you! I'll test that later today to confirm it's fixed.

@kerneltoast

Copy link
Copy Markdown
Author

That fix works. Closing this now as it's superfluous. Thanks again!

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.

2 participants