fix: quit once event stream closes in case terminal won't send a SIGHUP signal (#4052)

This commit is contained in:
三咲雅 misaki masa 2026-06-18 21:21:38 +08:00 committed by GitHub
parent 53d36b5186
commit 85132ff343
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 11 additions and 2 deletions

1
Cargo.lock generated
View file

@ -5316,6 +5316,7 @@ dependencies = [
"yazi-config",
"yazi-emulator",
"yazi-macro",
"yazi-proxy",
"yazi-shared",
"yazi-shim",
"yazi-term",

View file

@ -55,12 +55,16 @@ impl<'a> EventSource<'a> {
// More input is ready.
if read_ready {
let mut buf = [0u8; 1024];
let len = read_complete(&mut *reader, &mut buf)?;
if len == 0 {
return Err(io::Error::from(io::ErrorKind::UnexpectedEof));
}
let mut parser = self.parser.lock();
parser.parse(&buf[..len]);
if len > 0 && len < buf.len() {
if len < buf.len() {
parser.flush();
}
return Ok(());

View file

@ -31,7 +31,8 @@ impl EventStream {
break;
}
}
Err(e) if e.kind() == io::ErrorKind::Interrupted => break,
// try_poll() already handles Interrupted, this is defensive.
Err(e) if e.kind() == io::ErrorKind::Interrupted => continue,
Err(e) => {
tx.send(Err(e)).ok();
break;

View file

@ -16,6 +16,7 @@ workspace = true
yazi-config = { path = "../yazi-config", version = "26.5.6" }
yazi-emulator = { path = "../yazi-emulator", version = "26.5.6" }
yazi-macro = { path = "../yazi-macro", version = "26.5.6" }
yazi-proxy = { path = "../yazi-proxy", version = "26.5.6" }
yazi-shared = { path = "../yazi-shared", version = "26.5.6" }
yazi-shim = { path = "../yazi-shim", version = "26.5.6" }
yazi-term = { path = "../yazi-term", version = "26.5.6" }

View file

@ -5,6 +5,7 @@ use ratatui_core::{buffer::Buffer, layout::Rect, terminal::{CompletedFrame, Fram
use yazi_config::YAZI;
use yazi_emulator::{Emulator, Mux, TMUX};
use yazi_macro::writef;
use yazi_proxy::AppProxy;
use yazi_shim::cell::SyncCell;
use yazi_term::{TERM, event::{Event, KeyEventKind}, stream::EventStream};
use yazi_tty::{TTY, TtyWriter, sequence::{DisableBracketedPaste, DisableDrag, DisableDrop, DisableFocusChange, DisableMouseCapture, EnableBracketedPaste, EnableDrag, EnableDrop, EnableFocusChange, EnableMouseCapture, EnterAlternateScreen, If, LeaveAlternateScreen, PopKeyboardFlags, PushKeyboardFlags, RequestCursorBlink, RequestCursorStyle, RequestDA1, RequestKeyboardFlags, RestoreCursorStyle, SetTitle, ShowCursor}};
@ -105,6 +106,7 @@ impl Raterm {
_ => yazi_shared::event::Event::Term(event).emit(),
}
}
AppProxy::quit(Default::default());
});
}