diff options
| author | adamdottv <[email protected]> | 2025-05-01 07:58:27 -0500 |
|---|---|---|
| committer | adamdottv <[email protected]> | 2025-05-01 07:58:27 -0500 |
| commit | 7d5f0f9d18f327d0df89270a3b581ce4812f7638 (patch) | |
| tree | e0e7ef5d7fe8c60732e95c5238c9f200698d5694 | |
| parent | 515f4e864230e67f107cffe530633fd2aadc2b16 (diff) | |
| download | opencode-7d5f0f9d18f327d0df89270a3b581ce4812f7638.tar.gz opencode-7d5f0f9d18f327d0df89270a3b581ce4812f7638.zip | |
fix: pass input to EDITOR
| -rw-r--r-- | internal/tui/components/chat/editor.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/internal/tui/components/chat/editor.go b/internal/tui/components/chat/editor.go index 3548cbb0b..fea5d108b 100644 --- a/internal/tui/components/chat/editor.go +++ b/internal/tui/components/chat/editor.go @@ -45,13 +45,14 @@ var editorMaps = EditorKeyMaps{ ), } -func openEditor() tea.Cmd { +func openEditor(value string) tea.Cmd { editor := os.Getenv("EDITOR") if editor == "" { editor = "nvim" } tmpfile, err := os.CreateTemp("", "msg_*.md") + tmpfile.WriteString(value) if err != nil { return util.ReportError(err) } @@ -119,7 +120,9 @@ func (m *editorCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if m.app.CoderAgent.IsSessionBusy(m.session.ID) { return m, util.ReportWarn("Agent is working, please wait...") } - return m, openEditor() + value := m.textarea.Value() + m.textarea.Reset() + return m, openEditor(value) } // Handle Enter key if m.textarea.Focused() && key.Matches(msg, editorMaps.Send) { @@ -204,4 +207,3 @@ func NewEditorCmp(app *app.App) tea.Model { textarea: ta, } } - |
