From 2e727e568db26da277688f60b7b7017317b2f8b2 Mon Sep 17 00:00:00 2001 From: Bernhard Schuster Date: Thu, 16 Jul 2020 10:43:36 +0200 Subject: [PATCH] refactor/terminal: raw mode guard drop code simplification --- src/action/interactive.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/action/interactive.rs b/src/action/interactive.rs index 4d8eed60..b8228e5a 100644 --- a/src/action/interactive.rs +++ b/src/action/interactive.rs @@ -384,7 +384,7 @@ impl UserPicked { } loop { - let mut guard = ScopedRaw::new(); + let guard = ScopedRaw::new(); self.print_replacements_list(state)?; @@ -403,11 +403,14 @@ impl UserPicked { } let event = match crossterm::event::read() + .map(move |event| { + drop(guard); + event + }) .map_err(|e| anyhow::anyhow!("Something unexpected happened on the CLI: {}", e))? { Event::Key(event) => event, Event::Resize(..) => { - drop(guard); continue; } sth => { @@ -417,9 +420,8 @@ impl UserPicked { }; if state.is_custom_entry() { - drop(guard); info!("Custom entry mode"); - guard = ScopedRaw::new(); + let _guard = ScopedRaw::new(); let pick = self.enter_custom_replacement(state, event)?; @@ -435,7 +437,6 @@ impl UserPicked { } } - drop(guard); // print normally again trace!("registered event: {:?}", &event);