fix(tui): enter bash mode for large pasted ! commands - #2331
Conversation
Large pastes get folded into a marker, so checking getText() for a leading ! missed them. Use getExpandedText() instead.
🦋 Changeset detectedLatest commit: ed63e75 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: 420bcf4340
ℹ️ 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 (emptyPromptBeforeInput && this.inputMode === 'prompt' && this.getText().startsWith('!')) { | ||
| // Enter bash mode when `!...` is pasted into an empty prompt. Check | ||
| // getExpandedText() so folded large pastes still match on the leading `!`. | ||
| const expanded = this.getExpandedText(); |
There was a problem hiding this comment.
Avoid expanding folded pastes on every edit
When the editor already contains a folded paste marker, any subsequent keystroke reaches this line with emptyPromptBeforeInput === false, but getExpandedText() still expands every stored paste before the guard rejects the bash-mode path. For large pasted prompts, this re-materializes the hidden content on each edit and can make normal typing lag; compute the expanded text only after confirming the prompt was empty and still in prompt mode.
Useful? React with 👍 / 👎.
Addressing review feedback: getExpandedText() was running on every keystroke, re-materializing folded paste content each time. Move it inside the empty-prompt guard.
Related Issue
Resolve #2319
Problem
Pasting a shell command that starts with
!into an empty prompt only enters bash mode when the paste is small. Once it crosses the fold threshold (>1000 chars or >10 lines), pi-tui replaces it with a[paste #…]marker, and the editor was checkinggetText()for the leading!— so it never saw it and submitted the whole thing as a normal prompt.What changed
Switched that check to
getExpandedText()so we look at the real pasted content, not the marker. Same strip-the-!behavior as a short paste. Added tests around both fold boundaries.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.