@@ -21,9 +21,7 @@ type editorCmp struct {
2121 textarea textarea.Model
2222}
2323
24−type FocusEditorMsg bool
25−
26−type focusedEditorKeyMaps struct {
24+type EditorKeyMaps struct {
2725 Send key.Binding
2826 OpenEditor key.Binding
2927}
@@ -34,10 +32,10 @@ type bluredEditorKeyMaps struct {
3432 OpenEditor key.Binding
3533}
3634
37−var KeyMaps = focusedEditorKeyMaps{
35+var editorMaps = EditorKeyMaps{
3836 Send: key.NewBinding(
39− key.WithKeys("ctrl+s"),
40− key.WithHelp("ctrl+s", "send message"),
37+ key.WithKeys("enter", "ctrl+s"),
38+ key.WithHelp("enter", "send message"),
4139 ),
4240 OpenEditor: key.NewBinding(
4341 key.WithKeys("ctrl+e"),
@@ -107,29 +105,24 @@ func (m *editorCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
107105 m.session = msg
108106 }
109107 return m, nil
110− case FocusEditorMsg:
111− if msg {
112− m.textarea.Focus()
113− return m, tea.Batch(textarea.Blink, util.CmdHandler(EditorFocusMsg(true)))
114− }
115108 case tea.KeyMsg:
116109 if key.Matches(msg, messageKeys.PageUp) || key.Matches(msg, messageKeys.PageDown) ||
117110 key.Matches(msg, messageKeys.HalfPageUp) || key.Matches(msg, messageKeys.HalfPageDown) {
118111 return m, nil
119112 }
120− if key.Matches(msg, KeyMaps.OpenEditor) {
113+ if key.Matches(msg, editorMaps.OpenEditor) {
121114 if m.app.CoderAgent.IsSessionBusy(m.session.ID) {
122115 return m, util.ReportWarn("Agent is working, please wait...")
123116 }
124117 return m, openEditor()
125118 }
126119 // if the key does not match any binding, return
127− if m.textarea.Focused() && key.Matches(msg, KeyMaps.Send) {
120+ if m.textarea.Focused() && key.Matches(msg, editorMaps.Send) {
128121 return m, m.send()
129122 }
130−
123+
131124 // Handle Enter key
132− if m.textarea.Focused() && msg.String() == "enter" {
125+ if m.textarea.Focused() && key.Matches(msg, editorMaps.Send) {
133126 value := m.textarea.Value()
134127 if len(value) > 0 && value[len(value)-1] == '\\' {
135128 // If the last character is a backslash, remove it and add a newline
@@ -163,7 +156,7 @@ func (m *editorCmp) GetSize() (int, int) {
163156
164157func (m *editorCmp) BindingKeys() []key.Binding {
165158 bindings := []key.Binding{}
166− bindings = append(bindings, layout.KeyMapToSlice(KeyMaps)...)
159+ bindings = append(bindings, layout.KeyMapToSlice(editorMaps)...)
167160 return bindings
168161}
169162