editor now uses EDITOR env var
This commit is contained in:
parent
3ebe2ca035
commit
6414930dfb
|
@ -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)?;
|
||||
|
|
|
@ -5,12 +5,15 @@ use tempfile::NamedTempFile;
|
|||
|
||||
use crate::error::{Error::*, Result};
|
||||
|
||||
pub fn get_string(note_editor: Option<&String>) -> Result<String> {
|
||||
pub fn get_string(note_editor: Option<String>) -> Result<String> {
|
||||
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()
|
||||
|
|
Loading…
Reference in New Issue