Skip to content

Commit

Permalink
refactor/terminal: raw mode guard drop code simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
drahnr committed Jul 16, 2020
1 parent 06940a5 commit 2e727e5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/action/interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ impl UserPicked {
}

loop {
let mut guard = ScopedRaw::new();
let guard = ScopedRaw::new();

self.print_replacements_list(state)?;

Expand All @@ -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 => {
Expand All @@ -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)?;

Expand All @@ -435,7 +437,6 @@ impl UserPicked {
}
}

drop(guard);
// print normally again
trace!("registered event: {:?}", &event);

Expand Down

0 comments on commit 2e727e5

Please sign in to comment.