Skip to content

Commit

Permalink
fix: unwrap()-less implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Onciul committed Aug 30, 2024
1 parent 4c05b68 commit 651120a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,10 @@ impl Reedline {

let mut latest_resize = None;
loop {
if !self.reedline_event_queue.lock().unwrap().is_empty() {
break;
if let Ok(queue) = self.reedline_event_queue.lock() {
if !queue.is_empty() {
break;
}
}
match event::read()? {
Event::Resize(x, y) => {
Expand Down Expand Up @@ -804,9 +806,11 @@ impl Reedline {
reedline_events.push(ReedlineEvent::Edit(ec));
}

for event in self.reedline_event_queue.lock().unwrap().drain(..) {
println!("Got event from queue: {}", event);
reedline_events.push(event);
if let Ok(mut queue) = self.reedline_event_queue.lock() {
for event in queue.drain(..) {
println!("Got event from queue: {}", event);
reedline_events.push(event);
}
}

for event in reedline_events.drain(..) {
Expand Down

0 comments on commit 651120a

Please sign in to comment.