#3865·crush

External editor: quitting with an emptied buffer doesn't clear the composer

Author: soyomarvaldezgCreated Sep 16, 2026Updated Sep 17, 2026

Description

Opening the composer text in an external editor (ctrl+o, $EDITOR=nvim), deleting all text (e.g. ggdG), and quitting with :wq does not clear the composer — the previously typed message remains. Confirmed in plan mode and default (code) mode; yolo mode not yet tested.

To Reproduce

  1. EDITOR=nvim
  2. Type a message in the composer (multi-line makes it obvious)
  3. Press ctrl+o to open the buffer in the external editor
  4. Empty the buffer (ggdG), quit with :wq
  5. The composer still contains the original message

Expected behavior

Quitting the external editor with an empty buffer should clear the composer, consistent with clearing all text in the in-TUI editor.

Actual behavior

Composer text is unchanged; nothing is sent and there's no visible feedback.

Environment

  • crush v0.95.0
  • macOS 26.6.2 (Tahoe), Ghostty
  • $EDITOR=nvim

Likely cause (from reading the source — internal/ui/model/ui.go)

In openEditor() (~L4133), when the temp file comes back 0 bytes the function returns early:

go
if len(content) == 0 {
    return util.ReportWarn("Message is empty")
}
return openEditorMsg{Text: strings.TrimSpace(string(content))}

No openEditorMsg is emitted, so the handler at case openEditorMsg (~L1379) never runs and m.textarea keeps its old value. Neovim writes a 0-byte file for an emptied buffer, which hits this path. Fix idea: still emit openEditorMsg{Text: ""} (or otherwise clear the textarea) when the trimmed content is empty, instead of returning early.

cc @meowgorithm (confirmed this is a bug on Discord — thanks christian!)