Skip to content

Send a paste to the PTY in one write - #797

Merged
dakra merged 2 commits into
mainfrom
fix/paste-one-write
Nov 7, 2026
Merged

dakra merged 2 commits into
mainfrom
fix/paste-one-write

Conversation

@dakra

@dakra dakra commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

A paste went out as three writes: start bracket, text, end bracket. A terminal bridged through ghostel-pty-out-function can add a round trip between them. zsh ends a paste at any gap longer than KEYTIMEOUT (0.4s by default) and runs the pasted lines.

encodePaste now joins the frame and text into one buffer, so the hook gets a single call. The ghostel-pty-out-function docstring states that a paste must arrive without a pause.

Effect on bridged terminals

  • rexel: fixed. It sent the start bracket straight away and held the rest until the reply. The whole paste now goes out in one terminal.write.
  • ghostel-tmux: fixed for pastes that fit in one 512-byte send-keys chunk. Larger pastes are still split there, with a round trip between chunks.

Testing

  • make -j8 all passes, with LIBRARY_PATH set for a local emutls_w link problem.
  • New ghostel-test-paste-is-one-pty-write covers bracketed, unbracketed and empty pastes.
  • Real zsh 5.9, multi-line pastes up to 100 KB on the native and Emacs PTY backends: no pasted line ran. A control with a deliberate 1s gap did run lines.
  • Real tmux 3.8 with a script reproducing ghostel-tmux's chunking and a simulated round trip: no lines ran up to 0.2s, and lines ran from 0.35s for pastes over 512 bytes.
  • rexel's zsh-paste elate group (0.6s write delay, zsh 5.9): passes with this change. On 0.62.0 it fails: two of the three pasted lines ran before RET, and the last line got a stray ~ from the late end bracket.

dakra added 2 commits November 7, 2026 21:07
The start bracket, text and end bracket were separate writes.  A
terminal bridged through ghostel-pty-out-function can add a round trip
between them, and zsh ends a paste at any gap longer than KEYTIMEOUT
and runs the pasted lines.
paste-ghostel.json pastes into bash, zsh, fish, nu and the python3
REPL, on the native and the Emacs PTY, and checks with the shell's own
output that nothing runs before RET.  It covers multi-line, large,
multibyte, control-byte, embedded end-bracket, tab and CRLF pastes, a
program without bracketed paste, and every paste entry point.
@dakra
dakra merged commit 0e22056 into main Nov 7, 2026
27 checks passed
@dakra
dakra deleted the fix/paste-one-write branch November 7, 2026 23:32

This branch was previously deployed

1 inactive deployment
github-pages — 0e220566 Deployed Nov 7, 2026 by dakra via deploy #257
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