Round-seven fixes: swap name room for .tmp; input and notice details

- The shortened fallback swap name was capped at exactly NAME_MAX, so
  compaction's '<journal>.tmp' failed with ENAMETOOLONG on every
  checkpoint and the journal grew by a full copy of the buffer each
  time. Cap it at NAME_MAX - 4.
- A lone UTF-8 lead byte (8-bit Meta terminals) waited a second for
  continuation bytes on every key; wait 250 ms. An invalid byte now ends
  a pending ESC/C-k prefix instead of leaving it for the next key.
- Journal notices are shown after a deferred open's own status (which
  used to overwrite them), all pending ones at once, and the lock-out
  notice is not repeated after every save while the lock is still held.

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 78d78f6f54
commit b9f91b0ed2
6 changed files with 65 additions and 20 deletions
+11 -3
View File
@@ -393,9 +393,11 @@ read_key(int &ch, bool &is_keycode)
return true;
}
// The rest of the character is on its way; wait for it (restoring the
// caller's timeout), but not forever if it never comes.
// caller's timeout), but not long if it never comes: terminals that send
// Alt as a raw 8-bit byte (rxvt meta8) produce lone lead bytes, and
// every such key would otherwise stall input.
const int saved_delay = wgetdelay(stdscr);
timeout(1000);
timeout(250);
for (int i = 0; i < need; ++i) {
const int b = getch();
if (b == ERR || b > 0xFF || (b & 0xC0) != 0x80) {
@@ -427,7 +429,13 @@ TerminalInputHandler::decode_(MappedInput &out)
if (!read_key(ch, is_keycode))
return false; // no input
if (ch < 0) {
out.hasCommand = false; // invalid byte sequence, dropped
// Invalid byte sequence, dropped. It still ends a pending ESC or
// C-k prefix, as any other key would; left set, it applied to the
// next key instead.
esc_meta_ = false;
k_prefix_ = false;
k_ctrl_pending_ = false;
out.hasCommand = false;
return true;
}
bool consumed = map_key_to_command(