Skip to content

Commit 44e7447

Browse files
author
Stephan Dilly
committed
more clear error msg which env variables are checked for external editor (#426)
1 parent 9933607 commit 44e7447

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/components/externaleditor.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@ impl ExternalEditorComponent {
6666
io::stdout().execute(EnterAlternateScreen).expect("reset terminal");
6767
}
6868

69-
let editor = env::var("GIT_EDITOR")
69+
let environment_options = ["GIT_EDITOR", "VISUAL", "EDITOR"];
70+
71+
let editor = env::var(environment_options[0])
7072
.ok()
7173
.or_else(|| get_config_string(CWD, "core.editor").ok()?)
72-
.or_else(|| env::var("VISUAL").ok())
73-
.or_else(|| env::var("EDITOR").ok())
74+
.or_else(|| env::var(environment_options[1]).ok())
75+
.or_else(|| env::var(environment_options[2]).ok())
7476
.unwrap_or_else(|| String::from("vi"));
7577

7678
// TODO: proper handling arguments containing whitespaces
@@ -82,7 +84,10 @@ impl ExternalEditorComponent {
8284
let mut echars = editor.chars().peekable();
8385

8486
let first_char = *echars.peek().ok_or_else(|| {
85-
anyhow!("editor configuration set to empty string")
87+
anyhow!(
88+
"editor env variable found empty: {}",
89+
environment_options.join(" or ")
90+
)
8691
})?;
8792
let command: String = if first_char == '\"' {
8893
echars

0 commit comments

Comments
 (0)