feat(tui): expand paste markers on second paste#116
Conversation
When the cursor sits on a folded paste marker (e.g. `[paste #1 +15 lines]`) and the user pastes again (Ctrl-V or bracketed paste), the marker is expanded back to its original content instead of inserting new clipboard data.
🦋 Changeset detectedLatest commit: 0fbbd32 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fbb734da17
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Stop deleting the paste entry from the Map after expansion so that undo → re-expand still works.
commit: |
Accumulate chunks while consuming discarded paste data so a split ESC[201~ across chunks still resets consumingPaste.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0fbbd327a4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (this.consumeBuffer.includes(BRACKET_PASTE_END)) { | ||
| this.consumingPaste = false; | ||
| this.consumeBuffer = ''; | ||
| } | ||
| return; |
There was a problem hiding this comment.
Preserve input after the bracketed paste terminator
When consumingPaste is true and the terminal coalesces the bracketed-paste terminator with following input in the same data event, e.g. chunk\x1b[201~x after a marker expansion, this branch clears the consume state but still returns without replaying the bytes after \x1b[201~. That drops the user's first keystroke or escape sequence after the paste instead of handling it normally.
Useful? React with 👍 / 👎.
Related Issue
Problem
When pi-tui folds a large paste into a marker like
[paste #1 +15 lines], there is no way to expand it back in the editor. Users who want to review or edit the pasted content have to delete the marker and paste again.What changed
Added "second paste to expand" behavior to
CustomEditor: when the cursor sits on a folded paste marker and the user pastes again (via Ctrl-V or terminal bracketed paste), the marker is replaced with the original pasted content instead of inserting new clipboard data.Implementation details:
expandPasteMarkerAtCursor()— detects if the cursor is on a paste marker, retrieves the stored content from pi-tui's internalpastesMap, and replaces the marker viasetText()(which supports undo via Ctrl-Z).handleInput(): one for bracketed paste sequences (ESC[200~), one for the Ctrl-V keystroke (\x16). Both check for a marker at cursor before falling through to the normal paste flow.consumingPasteflag handles multi-chunk bracketed paste data — after expanding a marker, any remaining paste chunks from the terminal are discarded.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.