diff --git a/internal/tui/components/chat/editor/editor.go b/internal/tui/components/chat/editor/editor.go index 30d3aeef80c57487e665952f699cd7b4522db214..f910efee3b0924ebf2c5f9e77fcf5233ef909d93 100644 --- a/internal/tui/components/chat/editor/editor.go +++ b/internal/tui/components/chat/editor/editor.go @@ -245,7 +245,11 @@ func (m *editorCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.deleteMode = false return m, nil } - // Hanlde Enter key + if key.Matches(msg, m.keyMap.Newline) { + m.textarea.InsertRune('\n') + return m, nil + } + // Handle Enter key if m.textarea.Focused() && key.Matches(msg, m.keyMap.SendMessage) { value := m.textarea.Value() if len(value) > 0 && value[len(value)-1] == '\\' { diff --git a/internal/tui/components/chat/editor/keys.go b/internal/tui/components/chat/editor/keys.go index c64a92d526a1a81e558909fe5500b2bf1d4e3990..738e575db220960b2a25b7cfe847901d978786d4 100644 --- a/internal/tui/components/chat/editor/keys.go +++ b/internal/tui/components/chat/editor/keys.go @@ -8,6 +8,7 @@ type EditorKeyMap struct { AddFile key.Binding SendMessage key.Binding OpenEditor key.Binding + Newline key.Binding } func DefaultEditorKeyMap() EditorKeyMap { @@ -24,6 +25,10 @@ func DefaultEditorKeyMap() EditorKeyMap { key.WithKeys("ctrl+e"), key.WithHelp("ctrl+e", "open editor"), ), + Newline: key.NewBinding( + key.WithKeys("shift+enter", "ctrl+j"), + key.WithHelp("shift+enter", "newline"), key.WithHelp("ctrl+j", "newline"), + ), } } @@ -33,6 +38,7 @@ func (k EditorKeyMap) KeyBindings() []key.Binding { k.AddFile, k.SendMessage, k.OpenEditor, + k.Newline, } }