fix: preserve prompt_toolkit editor picker and mirror it in TUI

Base CLI's editor UX was better because prompt_toolkit picks the system
editor first, then friendly terminal editors before vi. Do not override
that with a vim-first chain.

Keep the CLI on prompt_toolkit's picker and only set tempfile_suffix='.md'
to avoid the complex-tempfile EEXIST path. Update the TUI resolver to
match prompt_toolkit's fallback order: $VISUAL, $EDITOR, editor, nano,
pico, vi, emacs.
This commit is contained in:
Brooklyn Nicholson
2026-04-25 20:20:05 -05:00
parent d056b610b7
commit 7fd8dc0bfb
3 changed files with 37 additions and 45 deletions

25
cli.py
View File

@@ -9789,31 +9789,6 @@ class HermesCLI:
# EEXIST. The suffix keeps markdown highlighting without that bug.
input_area.buffer.tempfile_suffix = '.md'
# prompt_toolkit's default fallback chain prefers /usr/bin/nano over
# /usr/bin/vi when neither $VISUAL nor $EDITOR is set. The TUI's
# resolveEditor() prefers nvim → vim → vi → nano. Override this single
# buffer's resolver so both surfaces pick the same editor.
import shlex
import subprocess
def _hermes_pick_editor(filename: str) -> bool:
chosen = (
os.environ.get('VISUAL')
or os.environ.get('EDITOR')
or shutil.which('nvim')
or shutil.which('vim')
or shutil.which('vi')
or shutil.which('nano')
)
if not chosen:
return False
try:
return subprocess.call(shlex.split(chosen) + [filename]) == 0
except OSError:
return False
input_area.buffer._open_file_in_editor = _hermes_pick_editor
# Dynamic height: accounts for both explicit newlines AND visual
# wrapping of long lines so the input area always fits its content.
def _input_height():