Skip to content

fix(config): respect $EDITOR when config editor is unset#1531

Closed
syf2211 wants to merge 0 commit into
sigoden:mainfrom
syf2211:fix/1527-editor-env-fallback
Closed

fix(config): respect $EDITOR when config editor is unset#1531
syf2211 wants to merge 0 commit into
sigoden:mainfrom
syf2211:fix/1527-editor-env-fallback

Conversation

@syf2211

@syf2211 syf2211 commented Jun 26, 2026

Copy link
Copy Markdown

Summary

When editor is not set in config.yaml, aichat should use $VISUAL or $EDITOR before falling back to nano/notepad.

Motivation

Fixes #1527. After #1082, Config::editor() validated the resolved editor with which::which(). If $EDITOR pointed to a valid editor that which could not resolve (common with custom install paths or editor commands with arguments), resolution failed and REPL editing fell back to nano.

Changes

  • Add resolve_editor() with priority: config → VISUALEDITOR → platform fallback
  • Trust explicit config/env editor values without a which check
  • Only validate the nano/notepad fallback with which
  • Parse editor commands via shell_words in edit_file and REPL buffer editor
  • Add unit tests for editor resolution

Tests

cargo test

All 26 tests pass.

Notes

Blank/whitespace editor: values in config are treated as unset so $EDITOR is honored.

@syf2211 syf2211 closed this Jun 27, 2026
@syf2211 syf2211 force-pushed the fix/1527-editor-env-fallback branch from 96204b5 to 82976d3 Compare June 27, 2026 07:06
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.

Use $EDITOR as default editor if set

1 participant