Editor: Empty content is discarded and cancellation not detected #8851

Open
opened 2026-02-16 18:11:01 -05:00 by yindo · 2 comments
Owner

Originally created by @nagarete on GitHub (Feb 8, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

The external editor integration (Ctrl+X E) has two bugs:

  1. Empty content discarded: When editing in an external editor and deleting all content, saving an empty file causes the original text to be retained instead of being cleared.

  2. Cancellation ignored: When quitting the external editor without saving (e.g., :q! in vim), any changes made in the editor are still applied to the input, even though the user cancelled.

Plugins

No plugins

OpenCode version

1.1.53

Steps to reproduce

Steps to reproduce (Issue 1):

  1. Type text in chat input
  2. Press Ctrl+X E to open editor
  3. Delete all text
  4. Save with :wq
  5. Expected: Empty input | Actual: Original text remains

Steps to reproduce (Issue 2):

  1. Type text in chat input
  2. Press Ctrl+X E to open editor
  3. Make changes
  4. Quit without saving :q!
  5. Expected: Original text unchanged | Actual: Editor changes applied

Screenshot and/or share link

No response

Operating System

Omarchy on Cachy Linux

Terminal

Ghossty

Originally created by @nagarete on GitHub (Feb 8, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description The external editor integration (Ctrl+X E) has two bugs: 1. Empty content discarded: When editing in an external editor and deleting all content, saving an empty file causes the original text to be retained instead of being cleared. 2. Cancellation ignored: When quitting the external editor without saving (e.g., :q! in vim), any changes made in the editor are still applied to the input, even though the user cancelled. ### Plugins No plugins ### OpenCode version 1.1.53 ### Steps to reproduce Steps to reproduce (Issue 1): 1. Type text in chat input 2. Press Ctrl+X E to open editor 3. Delete all text 4. Save with :wq 5. Expected: Empty input | Actual: Original text remains Steps to reproduce (Issue 2): 1. Type text in chat input 2. Press Ctrl+X E to open editor 3. Make changes 4. Quit without saving :q! 5. Expected: Original text unchanged | Actual: Editor changes applied ### Screenshot and/or share link _No response_ ### Operating System Omarchy on Cachy Linux ### Terminal Ghossty
yindo added the opentuibug labels 2026-02-16 18:11:01 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 8, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #7591: Empty editor content semantics - cancel vs. intentional clear (directly addresses the core ambiguity in this issue)
  • #3838: Lost @file references when opening prompt in external editor (content loss in editor)
  • #4015: Opening the editor essentially deletes pasted content (content discarding issue)
  • #3484: Fix TUI paste editor regression (content handling in editor)
  • #9860: Using emacs as editor + ctrl-g causes opencode to exit (external editor cancellation handling)
  • #4834: Crash After Exiting Editor (editor exit and content capture issues)
  • #2324: Cancelling causes context loss (related to cancellation detection)

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Feb 8, 2026): This issue might be a duplicate of existing issues. Please check: - #7591: Empty editor content semantics - cancel vs. intentional clear (directly addresses the core ambiguity in this issue) - #3838: Lost @file references when opening prompt in external editor (content loss in editor) - #4015: Opening the editor essentially deletes pasted content (content discarding issue) - #3484: Fix TUI paste editor regression (content handling in editor) - #9860: Using emacs as editor + ctrl-g causes opencode to exit (external editor cancellation handling) - #4834: Crash After Exiting Editor (editor exit and content capture issues) - #2324: Cancelling causes context loss (related to cancellation detection) Feel free to ignore if none of these address your specific case.
Author
Owner

@narasaka commented on GitHub (Feb 8, 2026):

looks like this issue still exists in 1.1.53 and looking at the code, it doesn't seem platform-specific.

@rekram1-node is it a feature? kinda feels like a bug. can confirm?

@narasaka commented on GitHub (Feb 8, 2026): looks like this issue still exists in 1.1.53 and looking at the code, it doesn't seem platform-specific. @rekram1-node is it a feature? kinda feels like a bug. can confirm?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8851