Skip to content

Commit

Permalink
ui: do not write() to channel if builtin pager has terminated
Browse files Browse the repository at this point in the history
  • Loading branch information
yuja committed Aug 4, 2024
1 parent 37ccfd5 commit 9f70289
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cli/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ impl Write for &BuiltinPager {
}

fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
// Since minus::Pager holds the rx end internally, push_str() doesn't
// fail even after the paging thread gets terminated.
if self.dynamic_pager_thread.is_finished() {
return Err(io::Error::new(io::ErrorKind::BrokenPipe, "pager quit"));
}
let string = std::str::from_utf8(buf).map_err(io::Error::other)?;
self.pager.push_str(string).map_err(io::Error::other)?;
Ok(buf.len())
Expand Down

0 comments on commit 9f70289

Please sign in to comment.