fix(cli): ignore literal Tab input in BaseTextInput#3270
fix(cli): ignore literal Tab input in BaseTextInput#3270tanzhenxin merged 2 commits intoQwenLM:mainfrom
Conversation
- Prevent insertion of literal tab characters in the BaseTextInput component - Require consumers to intercept Tab via onKeypress for custom behavior - Ensure smoother handling of Tab key without affecting buffer content
tanzhenxin
left a comment
There was a problem hiding this comment.
Review
Nice fix — the approach of guarding at both BaseTextInput and useTextBuffer layers is the right call, and the paste exception is handled correctly for the bracketed-paste path.
Issues
- Single-line paste regression on
pasteWorkaroundplatforms. On Windows / Node <20, thepasteWorkaroundpipeline forwards pasted content through the normal keypress path without settingpaste: true(seeKeypressContext.tsxflushRawBuffer— single-line data without\ris written directly tokeypressStreamwithout paste markers). This means tab characters in single-line pastes (e.g. tab-separated data from Excel) will be silently stripped by the new guard.
Verdict
COMMENT — The fix is correct for the standard path, but please verify behavior on the pasteWorkaround path before merging. Consider an approach that doesn't rely solely on the paste flag, or ensure the workaround path sets paste: true for forwarded content.
- Mark single-line raw chunks containing tabs as paste events in the pasteWorkaround path - Keep a literal Tab key as a non-paste keypress - Add KeypressContext coverage for literal Tab keys and single-line tab-separated raw chunks
Thanks for the review. I addressed this based on the suggested direction: the The PR now has two parts:
I also added tests covering both cases:
Validation: Result: 2 test files passed, 224 tests passed. Manual validation on Windows with This covers the |
|
Ran an e2e test plan against the latest commit (
LGTM from my side. Thanks for the quick turnaround on the follow-up commit. |

TLDR
Fixes Tab key handling in
BaseTextInput/useTextBufferso pressing Tab as a keypress no longer inserts a literal\tinto the input buffer.Screenshots / Video Demo
The before-fix behavior is shown in the video attached to the linked issue: #3268.
After fix: pressing Tab no longer changes the buffer content unless a consumer handles Tab explicitly.
No additional video is attached to this PR. The behavior was validated manually by pressing Tab in the interactive prompt and confirming that no literal tab was inserted.
Dive Deeper
Tab is used as a control key for completion, focus switching, and other consumer-specific behavior. When no consumer intercepted Tab, the default text-buffer insertion path could treat it as normal input and insert
\t.This change makes both
BaseTextInputanduseTextBufferignore non-paste Tab keypresses by default. Consumers that need Tab behavior should continue to intercept it viaonKeypress.Reviewer Test Plan
BaseTextInput.Testing Matrix
Windows validation:
npm run build.npm run bundle.node dist/cli.js.win32 x64, Qwen Code0.14.4.Linked issues / bugs
Fixes #3268