Terminal: apply ESC delay; stop treating resize as C-g

set_escdelay is an ncurses function, not a macro, so the #ifdef guard
compiled it out and ESC waited the 1 s default. KEY_RESIZE was mapped
to Refresh, the C-g cancel handler, which cleared the mark and
cancelled open prompts (including swap recovery) on every resize.

Audit findings B1, B2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015rcVQiiWyTzoNrsvLSaAfB
This commit is contained in:
Claude
2026-09-24 09:16:04 -07:00
committed by Kyle Isom
parent 1bdc04ce1a
commit 00098fee16
2 changed files with 7 additions and 4 deletions
+3 -1
View File
@@ -43,7 +43,9 @@ TerminalFrontend::Init(int &argc, char **argv, Editor &ed)
// Enable 8-bit meta key sequences (Alt/ESC-prefix handling in terminals) // Enable 8-bit meta key sequences (Alt/ESC-prefix handling in terminals)
meta(stdscr, TRUE); meta(stdscr, TRUE);
// Make ESC key sequences resolve quickly so ESC+<key> works as meta // Make ESC key sequences resolve quickly so ESC+<key> works as meta
#ifdef set_escdelay // set_escdelay is an ncurses extension function (not a macro), so test for
// ncurses itself rather than `#ifdef set_escdelay`, which is always false.
#if defined(NCURSES_VERSION)
set_escdelay(TerminalFrontend::kEscDelayMs); set_escdelay(TerminalFrontend::kEscDelayMs);
#endif #endif
// Make getch() block briefly instead of busy-looping; reduces CPU when idle // Make getch() block briefly instead of busy-looping; reduces CPU when idle
+4 -3
View File
@@ -165,9 +165,10 @@ map_key_to_command(const int ch,
out = {true, CommandId::DeleteChar, "", 0}; out = {true, CommandId::DeleteChar, "", 0};
return true; return true;
case KEY_RESIZE: case KEY_RESIZE:
k_prefix = false; // TerminalFrontend::Step picks up the new size before the next draw.
k_ctrl_pending = false; // Refresh is the C-g cancel handler, so issuing it here would clear the
out = {true, CommandId::Refresh, "", 0}; // mark and cancel open prompts on every window resize.
out.hasCommand = false;
return true; return true;
default: default:
break; break;