diff --git a/src/commands/in.rs b/src/commands/in.rs index 7f284ab..1abad5d 100644 --- a/src/commands/in.rs +++ b/src/commands/in.rs @@ -54,7 +54,7 @@ impl<'a> Command<'a> for InCommand { } else if !config.require_note { None } else { - Some(editor::get_string(config.note_editor.as_ref())?) + Some(editor::get_string(config.note_editor.clone())?) }; let (start, needs_warning) = time_or_warning(start, db)?; diff --git a/src/editor.rs b/src/editor.rs index 40e5bc0..698aa59 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -5,12 +5,15 @@ use tempfile::NamedTempFile; use crate::error::{Error::*, Result}; -pub fn get_string(note_editor: Option<&String>) -> Result { +pub fn get_string(note_editor: Option) -> Result { let note_editor = if let Some(note_editor) = note_editor { note_editor + } else if let Ok(editor_env) = std::env::var("EDITOR") { + editor_env } else { return Err(EditorIsEmpty); }; + let parts: Vec<_> = note_editor.split(' ').filter(|p| !p.is_empty()).collect(); let editor = if let Some(name) = parts.get(0) { name.to_owned()