Skip to content

feat: Handle Shift+Enter as prompt newline#52

Merged
qorzj merged 1 commit into
lessweb:mainfrom
Lellansin:dev/shift-enter-newline
May 13, 2026
Merged

feat: Handle Shift+Enter as prompt newline#52
qorzj merged 1 commit into
lessweb:mainfrom
Lellansin:dev/shift-enter-newline

Conversation

@Lellansin
Copy link
Copy Markdown
Contributor

@Lellansin Lellansin commented May 13, 2026

变更内容

  • 在 Prompt 激活时启用终端 extended key reporting,让支持该能力的终端可以区分 Shift+Enter 和普通 Enter。
  • 将普通 Enter 保持为提交 Prompt,Shift+Enter 作为插入换行处理。
  • 补充 Shift+Enter、普通 Enter、替代回车序列以及终端 escape helper 的单元测试。

背景

部分终端默认会把 Shift+Enter 和 Enter 都发送为相同的回车字符,导致应用无法判断用户是想换行还是提交。本次改动在 Prompt 生命周期内主动请求终端启用扩展按键模式,并兼容常见的 shifted return 序列。

验证

  • npm run test:single -- src/tests/promptInputKeys.test.ts
  • npm run check
  • npm test
  • codex review --base origin/main

@Lellansin Lellansin force-pushed the dev/shift-enter-newline branch 2 times, most recently from f51ff1e to 45e257e Compare May 13, 2026 08:13
@Lellansin Lellansin marked this pull request as ready for review May 13, 2026 08:19
@Lellansin Lellansin changed the title [codex] Handle Shift+Enter as prompt newline feat: Handle Shift+Enter as prompt newline May 13, 2026
Enable terminal extended key reporting while the prompt is active so terminals can distinguish Shift+Enter from plain Enter. Treat shifted return sequences as newline insertion while preserving plain Enter submission, and add unit coverage for the return-key behavior and terminal escape helpers.
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.

2 participants