Merge pull request #131 from Askhz/fix/ctrl-enter-newline

fix: 修复 Ctrl+Enter 在标准终端中应插入换行而非发送消息
This commit is contained in:
linkai0924 2026-05-19 20:50:33 +08:00 committed by GitHub
commit 9481d58c2b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View File

@ -697,12 +697,17 @@ function parseKeypress(s: string = ''): ParsedKey {
return createNavKey(s, 'mouse', false)
}
if (s === '\r' || s === '\r\n') {
if (s === '\r\n') {
key.raw = undefined
key.name = 'return'
key.ctrl = true
} else if (s === '\r') {
key.raw = undefined
key.name = 'return'
} else if (s === '\n') {
key.raw = undefined
key.name = 'return'
key.ctrl = true
} else if (s === '\t') {
key.name = 'tab'
} else if (s === '\b' || s === '\x1b\b') {

View File

@ -71,6 +71,9 @@ export const DEFAULT_BINDINGS: KeybindingBlock[] = [
'meta+o': 'chat:fastMode',
'meta+t': 'chat:thinkingToggle',
enter: 'chat:submit',
// Ctrl+Enter inserts a newline (Kitty keyboard protocol terminals only;
// standard terminals cannot distinguish ctrl+enter from plain enter).
'ctrl+enter': 'chat:newline',
up: 'history:previous',
down: 'history:next',
// Editing shortcuts (defined here, migration in progress)