From a3b49b17f4dfb788602a72f1a4e46ef872633112 Mon Sep 17 00:00:00 2001 From: Soispha Date: Mon, 24 Jul 2023 23:54:45 +0200 Subject: [PATCH] Fix(handlers::main): Close ci after a command input --- .../events/event_types/event/handlers/main.rs | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/tui_app/app/events/event_types/event/handlers/main.rs b/src/tui_app/app/events/event_types/event/handlers/main.rs index 6396ed1..ebb600f 100644 --- a/src/tui_app/app/events/event_types/event/handlers/main.rs +++ b/src/tui_app/app/events/event_types/event/handlers/main.rs @@ -135,26 +135,29 @@ pub async fn handle_normal(app: &mut App<'_>, input_event: &CrosstermEvent) -> R }; } central::InputPosition::CLI => { - if let Some(_) = app.ui.cli { + if let Some(cli) = &app.ui.cli { match input { CrosstermEvent::Key(KeyEvent { code: KeyCode::Enter, .. }) => { - let ci_event = app.ui - .cli - .as_mut() - .expect("This is already checked") - .lines() - .get(0) - .expect( - "There can only be one line in the buffer, as we collect it on enter being inputted" - ) - .to_owned(); + let ci_event = cli + .lines() + .get(0) + .expect( + "One line always exists, + and others can't exists + because we collect on + enter", + ) + .to_owned(); app.tx .send(Event::LuaCommand(ci_event)) .await .context("Failed to send lua command to internal event stream")?; + app.tx + .send(Event::CommandEvent(Command::CommandLineHide, None)) + .await?; } _ => { app.ui