[PR #3155] feat: Improve editor detection with auto-discovery and better error messages #10550

Closed
opened 2026-02-16 18:15:14 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/3155

State: closed
Merged: Yes


Summary

Improves the /editor command UX by automatically detecting available editors and providing helpful error messages when none are found.

Changes

  • Add GetEditor() utility function in packages/tui/internal/util/util.go:

    • Checks VISUAL environment variable first (standard for full-screen editors)
    • Falls back to EDITOR environment variable
    • Auto-detects common modern editors: VSCode (code), Cursor, Zed, Neovim (nvim), Vim, nano, vi
    • Platform-specific support (e.g., .cmd extensions and notepad.exe on Windows)
  • Update /editor command (EditorOpenCommand) to use new detection

  • Update /export command (SessionExportCommand) to use new detection

  • Provide helpful error message: "No editor found. Set EDITOR environment variable (e.g., export EDITOR=vim)"

Testing

Tested scenarios:

  • EDITOR set: uses specified editor
  • VISUAL set: prefers VISUAL over EDITOR
  • Neither set but common editor available: auto-detects (VSCode, Cursor, Neovim, Vim, Zed, etc.)
  • No editor available: shows helpful error with instructions

Related Issues

Resolves the issue where users get unhelpful "No EDITOR set" message without guidance on how to fix it.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/3155 **State:** closed **Merged:** Yes --- ## Summary Improves the `/editor` command UX by automatically detecting available editors and providing helpful error messages when none are found. ## Changes - Add `GetEditor()` utility function in `packages/tui/internal/util/util.go`: - Checks `VISUAL` environment variable first (standard for full-screen editors) - Falls back to `EDITOR` environment variable - Auto-detects common modern editors: **VSCode** (`code`), **Cursor**, **Zed**, **Neovim** (`nvim`), **Vim**, **nano**, **vi** - Platform-specific support (e.g., `.cmd` extensions and `notepad.exe` on Windows) - Update `/editor` command (EditorOpenCommand) to use new detection - Update `/export` command (SessionExportCommand) to use new detection - Provide helpful error message: "No editor found. Set EDITOR environment variable (e.g., export EDITOR=vim)" ## Testing Tested scenarios: - ✅ EDITOR set: uses specified editor - ✅ VISUAL set: prefers VISUAL over EDITOR - ✅ Neither set but common editor available: auto-detects (VSCode, Cursor, Neovim, Vim, Zed, etc.) - ✅ No editor available: shows helpful error with instructions ## Related Issues Resolves the issue where users get unhelpful "No EDITOR set" message without guidance on how to fix it.
yindo added the pull-request label 2026-02-16 18:15:14 -05:00
yindo closed this issue 2026-02-16 18:15:14 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#10550