BufReader doesn't retrun error on EOF

This commit is contained in:
Dongdong Zhou 2022-07-19 08:35:42 +01:00
parent 36c6c7d12f
commit 72db4dd382
1 changed files with 13 additions and 10 deletions

View File

@ -843,19 +843,22 @@ fn handle_stdout(&self, stdout: ChildStdout) {
fn handle_stderr(&self, stderr: ChildStderr, language_id: String) {
thread::spawn(move || {
let mut reader = Box::new(BufReader::new(stderr));
loop {
let mut buffer = String::new();
let mut buffer = String::new();
loop {
buffer.clear();
if reader.read_line(&mut buffer).is_err() {
return;
loop {
buffer.clear();
match reader.read_line(&mut buffer) {
Ok(bytes) => {
if bytes == 0 {
return;
}
}
if buffer.trim().is_empty() {
continue;
}
error!("[LSP::{}] {}", language_id, buffer.trim())
Err(_) => return,
}
if buffer.trim().is_empty() {
continue;
}
error!("[LSP::{}] {}", language_id, buffer.trim())
}
});
}