1
0
Fork 0

fix(key_input): Also input pending keys, when leaving KeyInputPending

This commit is contained in:
Benedikt Peetz 2023-10-18 23:09:09 +02:00
parent 0ed99b6244
commit 18152bdded
Signed by: bpeetz
GPG Key ID: A5E94010C3A642AD
1 changed files with 21 additions and 3 deletions

View File

@ -12,7 +12,25 @@ use crate::app::{
pub async fn handle(app: &mut App<'_>, input_event: &CrosstermEvent) -> Result<EventStatus> { pub async fn handle(app: &mut App<'_>, input_event: &CrosstermEvent) -> Result<EventStatus> {
async fn default(converted_key: Key, app: &mut App<'_>, old_state: &State) -> Result<()> { async fn default(converted_key: Key, app: &mut App<'_>, old_state: &State) -> Result<()> {
info!("No keymaps exist for key ('{}'), passing it along..", converted_key); info!(
"No keymaps exist for key ('{}'), passing it along..",
converted_key
);
if let State::KeyInputPending {
old_state: _,
pending_keys,
} = app.status.state().clone()
{
for key in pending_keys {
app.tx
.send(Event::CommandEvent(
Command::Trinitrix(Api(Raw(SendInputUnprocessed(key.to_string_repr())))),
None,
))
.await?;
}
app.status.set_state(old_state.to_owned());
}
// Just let the input event slip through if no keymap matches // Just let the input event slip through if no keymap matches
app.tx app.tx
.send(Event::CommandEvent( .send(Event::CommandEvent(
@ -22,7 +40,6 @@ pub async fn handle(app: &mut App<'_>, input_event: &CrosstermEvent) -> Result<E
None, None,
)) ))
.await?; .await?;
app.status.set_state(old_state.to_owned());
Ok(()) Ok(())
} }
@ -66,7 +83,8 @@ pub async fn handle(app: &mut App<'_>, input_event: &CrosstermEvent) -> Result<E
if possible_key_maps.len() == 1 { if possible_key_maps.len() == 1 {
let possible_key_map = possible_key_maps.get(0).expect("The len is 1"); let possible_key_map = possible_key_maps.get(0).expect("The len is 1");
if possible_key_map.is_child() && possible_key_map.is_terminal() && should_call { if possible_key_map.is_child() && possible_key_map.is_terminal() && should_call
{
let function = possible_key_map let function = possible_key_map
.value() .value()
.expect("This node is terminal and a child, it should have a value"); .expect("This node is terminal and a child, it should have a value");