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 {
|
} else if !config.require_note {
|
||||||
None
|
None
|
||||||
} else {
|
} 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)?;
|
let (start, needs_warning) = time_or_warning(start, db)?;
|
||||||
|
|
|
@ -5,12 +5,15 @@ use tempfile::NamedTempFile;
|
||||||
|
|
||||||
use crate::error::{Error::*, Result};
|
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 {
|
let note_editor = if let Some(note_editor) = note_editor {
|
||||||
note_editor
|
note_editor
|
||||||
|
} else if let Ok(editor_env) = std::env::var("EDITOR") {
|
||||||
|
editor_env
|
||||||
} else {
|
} else {
|
||||||
return Err(EditorIsEmpty);
|
return Err(EditorIsEmpty);
|
||||||
};
|
};
|
||||||
|
|
||||||
let parts: Vec<_> = note_editor.split(' ').filter(|p| !p.is_empty()).collect();
|
let parts: Vec<_> = note_editor.split(' ').filter(|p| !p.is_empty()).collect();
|
||||||
let editor = if let Some(name) = parts.get(0) {
|
let editor = if let Some(name) = parts.get(0) {
|
||||||
name.to_owned()
|
name.to_owned()
|
||||||
|
|
Loading…
Reference in New Issue