Skip to content

Commit

Permalink
fix: first char does not appear after pressing /
Browse files Browse the repository at this point in the history
This occurs becuase the event reading thread still waits for events
causing the search input reading thread to not read anything.

This reverts commit 99d163d.
  • Loading branch information
AMythicDev committed Jul 2, 2024
1 parent 202f6be commit dfa2de2
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/core/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,24 +336,28 @@ fn event_reader(
}
}

let ev = event::read().map_err(|e| MinusError::HandleEvent(e.into()))?;
let mut guard = ps.lock();
// Get the events
let input = guard.input_classifier.classify_input(ev, &guard);
if let Some(iev) = input {
if let InputEvent::Number(n) = iev {
guard.prefix_num.push(n);
guard.format_prompt();
if event::poll(std::time::Duration::from_millis(100))
.map_err(|e| MinusError::HandleEvent(e.into()))?
{
let ev = event::read().map_err(|e| MinusError::HandleEvent(e.into()))?;
let mut guard = ps.lock();
// Get the events
let input = guard.input_classifier.classify_input(ev, &guard);
if let Some(iev) = input {
if let InputEvent::Number(n) = iev {
guard.prefix_num.push(n);
guard.format_prompt();
} else if !guard.prefix_num.is_empty() {
guard.prefix_num.clear();
guard.format_prompt();
}
if let Err(TrySendError::Disconnected(_)) = evtx.try_send(Command::UserInput(iev)) {
break;
}
} else if !guard.prefix_num.is_empty() {
guard.prefix_num.clear();
guard.format_prompt();
}
if let Err(TrySendError::Disconnected(_)) = evtx.try_send(Command::UserInput(iev)) {
break;
}
} else if !guard.prefix_num.is_empty() {
guard.prefix_num.clear();
guard.format_prompt();
}
}
Result::<(), MinusError>::Ok(())
Expand Down

0 comments on commit dfa2de2

Please sign in to comment.