Skip to content

Commit

Permalink
get_editor : give priority to settings definition
Browse files Browse the repository at this point in the history
  • Loading branch information
ScriptSathi committed Sep 7, 2024
1 parent 5d2fabc commit 4550da2
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/cmd/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@ use crate::kubeconfig;
use crate::settings::Settings;

fn get_editor(settings: &Settings) -> Result<PathBuf> {
if let Some(default_editor) = &settings.default_editor {
if let Ok(path) = which(default_editor) {
return Ok(path);
}
}

env::var("EDITOR")
.ok()
.and_then(|editor| which(editor).ok())
.or_else(|| {
if settings.default_editor.is_some() {
if let Some(default_editor) = &settings.default_editor {
if let Ok(path) = which(default_editor.as_str()) {
return Some(path);
}
}
}

for editor in &["nvim", "vim", "emacs", "vi", "nano"] {
if let Ok(path) = which(editor) {
return Some(path);
Expand Down

0 comments on commit 4550da2

Please sign in to comment.