Read editor from configuration, ignore errors

This commit is contained in:
Matthias Beyer 2018-03-12 23:20:13 +01:00
parent 5dc0bd9db2
commit b8c3f7f834

View file

@ -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());