Skip to content

Conversation

affaan-m
Copy link

@affaan-m affaan-m commented Oct 13, 2025

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.

- Add GetEditor() utility that checks VISUAL, EDITOR env vars and auto-detects common editors
- Support modern editors: VSCode (code), Cursor, Zed, and traditional editors (nvim, vim, nano, vi)
- Update /editor and /export commands to use new detection
- Provide helpful error message with instructions when no editor found
- Support platform-specific defaults (notepad, .cmd extensions on Windows)
@affaan-m affaan-m force-pushed the improve-editor-detection branch from 62eaf50 to 4d4640d Compare October 13, 2025 23:05
@affaan-m affaan-m changed the title Improve editor detection with auto-discovery and better error messages feat: Improve editor detection with auto-discovery and better error messages Oct 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant