Skip to main content

spawn_editor

Function spawn_editor 

Source
pub fn spawn_editor(template: &str) -> Result<String>
Expand description

Spawn the user’s editor on a tempfile pre-populated with template, then read the file back, strip #-comment lines, and return the trimmed result.

The editor is chosen in this order:

  1. $GIT_EDITOR
  2. $EDITOR
  3. $VISUAL
  4. platform default (vi on Unix, notepad on Windows)

The editor invocation parses the chosen value as a shell-like command: the first whitespace-separated token is the program, the rest are arguments, and the tempfile path is appended as a final argument. This matches how git’s GIT_EDITOR is conventionally parsed (e.g. EDITOR="vim -c 'set nowrap'").

§Errors