diff --git a/internal/tui/components/chat/editor/editor.go b/internal/tui/components/chat/editor/editor.go index ee374a6c1e0e68aaebef74fee07edb62292d68fe..272ef2f8f78020a16e88e5eac73756ea8473fe4b 100644 --- a/internal/tui/components/chat/editor/editor.go +++ b/internal/tui/components/chat/editor/editor.go @@ -67,6 +67,10 @@ const ( maxAttachments = 5 ) +type openEditorMsg struct { + Text string +} + func (m *editorCmp) openEditor(value string) tea.Cmd { editor := os.Getenv("EDITOR") if editor == "" { @@ -102,11 +106,8 @@ func (m *editorCmp) openEditor(value string) tea.Cmd { return util.ReportWarn("Message is empty") } os.Remove(tmpfile.Name()) - attachments := m.attachments - m.attachments = nil - return chat.SendMsg{ - Text: string(content), - Attachments: attachments, + return openEditorMsg{ + Text: strings.TrimSpace(string(content)), } }) } @@ -184,6 +185,9 @@ func (m *editorCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.completionsStartIndex = 0 return m, nil } + case openEditorMsg: + m.textarea.SetValue(msg.Text) + return m, nil case tea.KeyPressMsg: switch { // Completions