Fallback for config.buffer_editor from EDITOR (#5614)

For the reedline `buffer_editor` use the `EDITOR` and `VISUAL`
environment variables as fallback.

Same resolution order as #5607

Closes #5430
This commit is contained in:
Stefan Holderbach
2022-05-22 19:32:52 +02:00
committed by GitHub
parent 6ff717c0ba
commit 0e1bfae13d
2 changed files with 21 additions and 2 deletions

View File

@ -159,7 +159,26 @@ pub fn evaluate_repl(
}
};
line_editor = line_editor.with_buffer_editor(config.buffer_editor.clone(), "nu".into());
let buffer_editor = if !config.buffer_editor.is_empty() {
Some(config.buffer_editor.clone())
} else {
stack
.get_env_var(engine_state, "EDITOR")
.map(|v| v.as_string().unwrap_or_default())
.filter(|v| !v.is_empty())
.or_else(|| {
stack
.get_env_var(engine_state, "VISUAL")
.map(|v| v.as_string().unwrap_or_default())
.filter(|v| !v.is_empty())
})
};
line_editor = if let Some(buffer_editor) = buffer_editor {
line_editor.with_buffer_editor(buffer_editor, "nu".into())
} else {
line_editor
};
if config.sync_history_on_enter {
if is_perf_true {