From 5f20121de847feef163b4a0449d78d63a4645896 Mon Sep 17 00:00:00 2001 From: pengdst Date: Fri, 3 Jul 2026 22:55:34 +0700 Subject: [PATCH] feat: support shift enter for composer newlines --- internal/tui/composer.go | 2 +- internal/tui/composer_test.go | 3 ++- internal/tui/keybinding_help.go | 2 +- internal/tui/model.go | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/tui/composer.go b/internal/tui/composer.go index 400509b2..91a3bf85 100644 --- a/internal/tui/composer.go +++ b/internal/tui/composer.go @@ -306,7 +306,7 @@ func (m model) composerPositionAtVisualCell(x int, y int, width int) (int, bool) func (m model) applyComposerKey(msg tea.KeyMsg) (model, bool) { state := m.currentComposerState() switch { - case keyIs(msg, tea.KeyEnter) && keyAlt(msg): + case keyIs(msg, tea.KeyEnter) && (keyAlt(msg) || keyShift(msg)): m = m.insertComposerTextWithPastePreview(state, "\n", "") case keyCtrl(msg, 'j'): m = m.insertComposerTextWithPastePreview(state, "\n", "") diff --git a/internal/tui/composer_test.go b/internal/tui/composer_test.go index 6ba7717a..f1adfd91 100644 --- a/internal/tui/composer_test.go +++ b/internal/tui/composer_test.go @@ -299,7 +299,8 @@ func TestModifiedEnterInsertsNewlineWithoutSubmitting(t *testing.T) { key tea.Msg }{ {name: "alt enter", key: testKeyAlt(tea.KeyEnter)}, - {name: "shift enter", key: testKeyCtrl('j')}, + {name: "shift enter", key: testKeyShift(tea.KeyEnter)}, + {name: "ctrl j", key: testKeyCtrl('j')}, } for _, tc := range tests { diff --git a/internal/tui/keybinding_help.go b/internal/tui/keybinding_help.go index f37a50be..401ff785 100644 --- a/internal/tui/keybinding_help.go +++ b/internal/tui/keybinding_help.go @@ -36,7 +36,7 @@ func (m model) buildKeybindingGroups() []keybindingGroup { title: "Chat", bindings: []keybinding{ {"Enter", "send the message"}, - {"Alt+Enter", "insert a newline (multi-line compose)"}, + {"Shift+Enter / Alt+Enter", "insert a newline (multi-line compose)"}, {"Esc (\u00d72)", "cancel the run / dismiss a popup / clear the input"}, {"Ctrl+C", "cancel the run, then quit"}, {"?", "show this help (on an empty input)"}, diff --git a/internal/tui/model.go b/internal/tui/model.go index 766f9ab9..fa1b78b0 100644 --- a/internal/tui/model.go +++ b/internal/tui/model.go @@ -1239,7 +1239,7 @@ func (m model) updateModel(msg tea.Msg) (tea.Model, tea.Cmd) { if m.picker != nil { return m.choosePicker() } - if keyAlt(msg) { + if keyAlt(msg) || keyShift(msg) { if next, ok := m.applyComposerKey(msg); ok { return next, nil }