Repository navigation
fix(web): terminal paste no longer doubles when the clipboard read wins - #29
Merged
Merged
Conversation
The paste shortcut races navigator.clipboard.readText() against the browser's native paste event. The token only covered the native event landing first; when the read resolved first, the native paste that followed was sent again. Record the text the read delivered and drop the matching native paste of the same gesture.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pasting into the terminal from a browser (for example over the network) sometimes sends the text twice.
The paste shortcut starts
navigator.clipboard.readText()and also keeps the browser's nativepasteevent. The shared token only handled the native event landing first. When the read resolved first, the native paste that followed was sent too. Upstream noted this remaining ordering when closing pingdotgg#8457, and there is no upstream issue for it yet.The read now records the text it delivered. The next native paste with the same text is dropped, and any keydown clears the record so a later paste gesture is never swallowed.
Verification
surface.test.tsresolves the read before dispatching the native paste. It fails on the old code (2 writes) and passes with the fix, and it covers the next gesture still pasting.vp test run src/terminal/ghostty/surface.test.ts: 55 passing. Lint andtsc --noEmitforapps/webare clean.