fix: When EDITOR, VISUAL, or config.editor is defined, don't verify via which
This commit is contained in:
@@ -311,16 +311,17 @@ impl AppConfig {
|
|||||||
|
|
||||||
pub fn editor(&self) -> Result<String> {
|
pub fn editor(&self) -> Result<String> {
|
||||||
super::EDITOR.get_or_init(move || {
|
super::EDITOR.get_or_init(move || {
|
||||||
let editor = self.editor.clone()
|
if let Some(editor) = self.editor.clone()
|
||||||
.or_else(|| env::var("VISUAL").ok().or_else(|| env::var("EDITOR").ok()))
|
.or_else(|| env::var("VISUAL").ok().or_else(|| env::var("EDITOR").ok()))
|
||||||
.unwrap_or_else(|| {
|
{
|
||||||
if cfg!(windows) {
|
return Some(editor);
|
||||||
|
}
|
||||||
|
let default = if cfg!(windows) {
|
||||||
"notepad".to_string()
|
"notepad".to_string()
|
||||||
} else {
|
} else {
|
||||||
"nano".to_string()
|
"nano".to_string()
|
||||||
}
|
};
|
||||||
});
|
which::which(&default).ok().map(|_| default)
|
||||||
which::which(&editor).ok().map(|_| editor)
|
|
||||||
})
|
})
|
||||||
.clone()
|
.clone()
|
||||||
.ok_or_else(|| anyhow!("Editor not found. Please add the `editor` configuration or set the $EDITOR or $VISUAL environment variable."))
|
.ok_or_else(|| anyhow!("Editor not found. Please add the `editor` configuration or set the $EDITOR or $VISUAL environment variable."))
|
||||||
|
|||||||
Reference in New Issue
Block a user