mirror of
https://github.com/helix-editor/termina.git
synced 2025-10-06 00:22:43 +02:00
fix: ensure try_read always reads at least once (#10)
This commit is contained in:
@@ -82,7 +82,7 @@ impl EventSource for UnixEventSource {
|
||||
fn try_read(&mut self, timeout: Option<Duration>) -> io::Result<Option<Event>> {
|
||||
let timeout = PollTimeout::new(timeout);
|
||||
|
||||
while timeout.leftover().map_or(true, |t| !t.is_zero()) {
|
||||
loop {
|
||||
if let Some(event) = self.parser.pop() {
|
||||
return Ok(Some(event));
|
||||
}
|
||||
@@ -136,6 +136,10 @@ impl EventSource for UnixEventSource {
|
||||
"Poll operation was woken up",
|
||||
));
|
||||
}
|
||||
|
||||
if timeout.leftover().is_some_and(|t| t.is_zero()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(None)
|
||||
|
@@ -41,7 +41,7 @@ impl EventSource for WindowsEventSource {
|
||||
|
||||
let timeout = PollTimeout::new(timeout);
|
||||
|
||||
while timeout.leftover().map_or(true, |t| !t.is_zero()) {
|
||||
loop {
|
||||
if let Some(event) = self.parser.pop() {
|
||||
return Ok(Some(event));
|
||||
}
|
||||
@@ -81,6 +81,10 @@ impl EventSource for WindowsEventSource {
|
||||
let records = self.input.read_console_input(pending)?;
|
||||
|
||||
self.parser.decode_input_records(&records);
|
||||
|
||||
if timeout.leftover().is_some_and(|t| t.is_zero()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(None)
|
||||
|
Reference in New Issue
Block a user