term: Improve errors when editor can't be spawned
This commit is contained in:
parent
0581c017ae
commit
9f4227d378
|
|
@ -83,13 +83,25 @@ impl Editor {
|
||||||
process::Stdio::from(tty)
|
process::Stdio::from(tty)
|
||||||
};
|
};
|
||||||
|
|
||||||
process::Command::new(cmd)
|
process::Command::new(&cmd)
|
||||||
.stdout(unsafe { process::Stdio::from_raw_fd(stderr) })
|
.stdout(unsafe { process::Stdio::from_raw_fd(stderr) })
|
||||||
.stderr(process::Stdio::inherit())
|
.stderr(process::Stdio::inherit())
|
||||||
.stdin(stdin)
|
.stdin(stdin)
|
||||||
.arg(&self.path)
|
.arg(&self.path)
|
||||||
.spawn()?
|
.spawn()
|
||||||
.wait()?;
|
.map_err(|e| {
|
||||||
|
io::Error::new(
|
||||||
|
e.kind(),
|
||||||
|
format!("failed to spawn editor command {cmd:?}: {e}"),
|
||||||
|
)
|
||||||
|
})?
|
||||||
|
.wait()
|
||||||
|
.map_err(|e| {
|
||||||
|
io::Error::new(
|
||||||
|
e.kind(),
|
||||||
|
format!("editor command {cmd:?} didn't spawn: {e}"),
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
|
||||||
let text = fs::read_to_string(&self.path)?;
|
let text = fs::read_to_string(&self.path)?;
|
||||||
if text.trim().is_empty() {
|
if text.trim().is_empty() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue