From 45361460cfbeb3c543674c36fc5cad5166d596d2 Mon Sep 17 00:00:00 2001 From: "DAVID, Jerome" Date: Mon, 31 Jul 2023 00:25:53 +0200 Subject: [PATCH] Since 0.26, crossterm detects key release events on Windows. As a consequence, key events were handled twice, one for key press and one for key release. (#78) This fixes the issue by ignoring events when the type is not a key press. See relevant issue on crossterm: https://github.com/crossterm-rs/crossterm/issues/797 --- src/app.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/app.rs b/src/app.rs index aede35f..eaf9ccb 100644 --- a/src/app.rs +++ b/src/app.rs @@ -6,7 +6,7 @@ use std::{error::Error, fs::File, process}; use arboard::Clipboard; -use crossterm::event::{self, Event}; +use crossterm::event::{self, Event, KeyEventKind}; use crate::buffer::AsyncBuffer; use crate::decoder::Encoding; @@ -219,8 +219,10 @@ impl Application { let event = event::read()?; match event { Event::Key(key) => { - self.labels.notification.clear(); - return input::handle_key_input(self, key); + if key.kind == KeyEventKind::Press { + self.labels.notification.clear(); + return input::handle_key_input(self, key); + } } Event::Mouse(mouse) => { self.labels.notification.clear();