fix(editor): default to vi when no editor is set (#1811)

* fix(editor): default to vi when no editor is set

* style(fmt): rustfmt
This commit is contained in:
Aram Drevekenin 2022-10-18 17:33:48 +02:00 committed by GitHub
parent 5c8cded2f5
commit 617b52f8f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 8 deletions

View file

@ -245,15 +245,11 @@ fn spawn_terminal(
let mut failover_cmd_args = None;
let cmd = match terminal_action {
TerminalAction::OpenFile(file_to_open, line_number) => {
if default_editor.is_none()
&& env::var("EDITOR").is_err()
&& env::var("VISUAL").is_err()
{
return Err(SpawnTerminalError::NoEditorFound);
}
let mut command = default_editor.unwrap_or_else(|| {
PathBuf::from(env::var("EDITOR").unwrap_or_else(|_| env::var("VISUAL").unwrap()))
PathBuf::from(
env::var("EDITOR")
.unwrap_or_else(|_| env::var("VISUAL").unwrap_or_else(|_| "vi".into())),
)
});
let mut args = vec![];

View file

@ -136,6 +136,7 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: Box<Layout>) {
);
}
} else {
log::error!("Failed to spawn terminal: command not found");
pty.close_pane(PaneId::Terminal(pid));
}
},