Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
Fix buffer not being read correctly.
Browse files Browse the repository at this point in the history
Relates #223, but not sure it fixes it. I want to redesign the whole buffer streaming (#249) so this is a temporary fix
until we got something more robust — along with lazy commands (#240).

Thanks [@robem](#223 (comment)) for suggesting the
fix.
  • Loading branch information
hadronized committed Apr 24, 2024
1 parent 8660526 commit c2f07ec
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions kak-tree-sitter/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -889,17 +889,25 @@ impl FifoHandler {
session_name = session.name()
);

if let Err(err) = file.read_to_string(buffer) {
if err.kind() == io::ErrorKind::WouldBlock {
log::debug!("buffer FIFO is not ready");
return Ok(());
} else {
return Err(OhNo::InvalidRequest {
req: "<buf>".to_owned(),
err: err.to_string(),
});
let mut tmp = String::new();
loop {
match file.read_to_string(&mut tmp) {
Ok(0) => break,
Ok(_) => buffer.push_str(&tmp),
Err(err) => {
if err.kind() == io::ErrorKind::WouldBlock {
log::debug!("buffer FIFO is not ready");
continue;
// return Ok(());
} else {
return Err(OhNo::InvalidRequest {
req: "<buf>".to_owned(),
err: err.to_string(),
});
}
}
}
};
}

let res = self.process_buf(session, buffer);
buffer.clear();
Expand Down

0 comments on commit c2f07ec

Please sign in to comment.