on main help sign in
fix(ui): clean up temp file on error in openEditor

If WriteString or editor.Command failed, the temp file was closed but never removed, leaking files in the system temp directory. Now os.Remove is called on both error paths before returning.

commit68c502645de595665de2b40f4e84126ea32be999 authoriko <mail@iko.soy> dateThu 9 Jul 2026, 03:42 (3 months ago) parentb203f9c
1 file changed+2
internal/ui/model/ui.go+2
internal/ui/model/ui.go+2
@@ -3307,6 +3307,7 @@ func (m *UI) openEditor(value string) tea.Cmd {
33073307 tmpPath := tmpfile.Name()
33083308 defer tmpfile.Close()
33093309 if _, err := tmpfile.WriteString(value); err != nil {
3310+ _ = os.Remove(tmpPath)
33103311 return util.ReportError(err)
33113312 }
33123313 cmd, err := editor.Command(
@@ -3318,6 +3319,7 @@ func (m *UI) openEditor(value string) tea.Cmd {
33183319 ),
33193320 )
33203321 if err != nil {
3322+ _ = os.Remove(tmpPath)
33213323 return util.ReportError(err)
33223324 }
33233325 return tea.ExecProcess(cmd, func(err error) tea.Msg {