Question: Empty editor content semantics - cancel vs. intentional clear?
Question: Empty editor content semantics - cancel vs. intentional clear?
Context
The Editor.open() utility in src/cli/cmd/tui/util/editor.ts currently uses return content || undefined, which converts empty string "" to undefined. Callers (e.g., prompt component) then use if (!content) return, treating an empty editor result as "cancel/abort".
This behavior is ambiguous and non-obvious to users: clearing the entire buffer in $EDITOR and saving feels like "I want to clear this", but it's interpreted as "cancel/abort operation".
History
- Oct 12, 2025: Original implementation used
content || undefinedfrom day one - Dec 19, 2025: A test was added expecting empty string to be preserved:
However, code fix to make this test pass was never committedtest("returns empty string when editor clears file", async () => { // ... expect(result).toBe("") })
Inconsistency in Export Flow
The export functionality uses Editor.open() but handles result differently than prompt flow—one treats empty as cancel, another may treat it differently. This makes behavior unpredictable depending on which feature you're using.
Testing
Version: 1.1.11 (tested locally)
Local fix: I have implemented a fix that treats undefined as cancel but preserves "" as a valid result:
Editor.open()now returnscontentdirectly (no|| undefinedcoercion)- Callers check
if (content === undefined) return - Test passes with this fix
Question
Is the intended behavior:
- A) Empty editor content = cancel/abort (current code behavior)
- B) Empty editor content = valid result/intentional clear (as Dec 19 test expects)
Environment
- OpenCode: 1.1.11
- Platform: macOS 26.0.1
- Editor: Neovim