Fix stdout/stderr not being detected in proc response when no newline was provided

pull/38/head v0.7.1
Chip Senkbeil 3 years ago
parent b3a4d79507
commit cbefdb69ec
No known key found for this signature in database
GPG Key ID: 35EF1F8EC72A4131

@ -2,7 +2,7 @@
name = "distant"
description = "Operate on a remote computer through file and process manipulation"
categories = ["command-line-utilities"]
version = "0.7.0"
version = "0.7.1"
authors = ["Chip Senkbeil <chip@senkbeil.org>"]
edition = "2018"
homepage = "https://github.com/chipsenkbeil/distant"

@ -230,9 +230,26 @@ pub enum ResponseOut {
impl ResponseOut {
pub fn print(self) {
match self {
Self::Stdout(x) => print!("{}", x),
Self::Stdout(x) => {
// NOTE: Because we are not including a newline in the output,
// it is not guaranteed to be written out. In the case of
// LSP protocol, the JSON content is not followed by a
// newline and was not picked up when the response was
// sent back to the client; so, we need to manually flush
use std::io::Write;
print!("{}", x);
if let Err(x) = std::io::stdout().lock().flush() {
error!("Failed to flush stdout: {}", x);
}
}
Self::StdoutLine(x) => println!("{}", x),
Self::Stderr(x) => eprint!("{}", x),
Self::Stderr(x) => {
use std::io::Write;
eprint!("{}", x);
if let Err(x) = std::io::stderr().lock().flush() {
error!("Failed to flush stderr: {}", x);
}
}
Self::StderrLine(x) => eprintln!("{}", x),
Self::None => {}
}

Loading…
Cancel
Save