Read editor from configuration, ignore errors
This commit is contained in:
parent
5dc0bd9db2
commit
b8c3f7f834
1 changed files with 9 additions and 0 deletions
|
@ -25,6 +25,7 @@ use std::io::Stdin;
|
|||
|
||||
pub use clap::App;
|
||||
use toml::Value;
|
||||
use toml_query::read::TomlValueReadExt;
|
||||
|
||||
use clap::{Arg, ArgMatches};
|
||||
|
||||
|
@ -457,7 +458,15 @@ impl<'a> Runtime<'a> {
|
|||
self.cli()
|
||||
.value_of("editor")
|
||||
.map(String::from)
|
||||
.or_else(|| {
|
||||
self.config()
|
||||
.and_then(|v| match v.read("rt.editor") {
|
||||
Ok(Some(&Value::String(ref s))) => Some(s.clone()),
|
||||
_ => None, // FIXME silently ignore errors in config is bad
|
||||
})
|
||||
})
|
||||
.or(env::var("EDITOR").ok())
|
||||
.map(|s| {debug!("Editing with '{}'", s); s})
|
||||
.map(|s| {
|
||||
let mut c = Command::new(s);
|
||||
c.stdin(::std::process::Stdio::inherit());
|
||||
|
|
Loading…
Reference in a new issue