Skip to content

Fix ghostel-debug-info report truncation and dead key-encoding probe#501

Merged
dakra merged 1 commit into
mainfrom
fix-debug-info-probe
Jul 3, 2026
Merged

Fix ghostel-debug-info report truncation and dead key-encoding probe#501
dakra merged 1 commit into
mainfrom
fix-debug-info-probe

Conversation

@dakra

@dakra dakra commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Problem

M-x ghostel-debug-info produced a nearly empty report: only a headerless tail of the key-encoding table plus the non-default-settings section survived, and the encoder chords all showed (no output).

Two regressions from the 0.40 renderer/PTY rework:

  1. Report wiped by the probe terminal. Since the renderer became buffer-affine (679b113), ghostel--new erases the current buffer on init. The key-encoding probe was created with *ghostel-debug* current, silently wiping every section inserted before it (System, Ghostel, Frame, Environment, Buffer, Process, …). No error was signaled.
  2. Encoder byte capture dead. The probe captured bytes by overriding the elisp ghostel--write-pty, but the native PTY path (40f1269) writes the PTY directly from Zig and never calls it — and silently drops bytes when no process is live. Only the elisp raw-fallback chords (M-f/M-b/M-.) still showed bytes. ghostel-debug-keypress had the same blindness via its ghostel--write-pty advice.

Fix

  • Create the probe terminal and run all encodes inside with-temp-buffer, so the buffer-affine init can't touch *ghostel-debug*.
  • ghostel--encode-key now returns the encoded bytes as a unibyte string (nil when the encoder produced nothing) instead of t. The live send path only tests truthiness and is unchanged; no extra heap on the Zig side (the stack buffer moved to the caller). The probe reads bytes from the return value, and ghostel-debug-keypress records them via :filter-return advice.

Verification

  • make -j8 all passes; two new native ERT tests (report survives the probe; ghostel--encode-key returns 0x7f for Backspace).
  • Live-verified under elate: all 13 report sections present, every chord shows real bytes (Backspace → 0x7f, C-M-f → 0x1b 0x06, M-Backspace → 0x1b 0x7f), and ghostel-debug-keypress on Backspace records encode-key: hex 7f.

@dakra
dakra requested a review from emil-e July 2, 2026 11:31
Since the renderer became buffer-affine (679b113), ghostel--new erases
the current buffer on init.  ghostel-debug-info created its key-encoding
probe terminal with *ghostel-debug* current, silently wiping every
report section inserted before the probe.  Create the probe and run all
encodes in a temp buffer instead.

The probe also captured encoder bytes by overriding the elisp
ghostel--write-pty, which the native PTY path (40f1269) no longer
calls, so every encoder-handled chord reported "(no output)".  Make
ghostel--encode-key return the encoded bytes as a unibyte string (nil
when the encoder produced nothing) and read them from the return value;
the live send path only tests truthiness and is unchanged.  The same
change lets ghostel-debug-keypress record encoder bytes again via
:filter-return advice.
@dakra
dakra force-pushed the fix-debug-info-probe branch from a8fa43a to f23b033 Compare July 3, 2026 16:22
@dakra
dakra merged commit f23b033 into main Jul 3, 2026
23 of 24 checks passed
@dakra
dakra deleted the fix-debug-info-probe branch July 3, 2026 16:28
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