From 8b5a235129a024c213fa088b41395bced5837ae0 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 8 Feb 2024 16:03:26 -0700 Subject: [PATCH] Do not clone Key --- src/key_bind.rs | 4 ++-- src/main.rs | 2 +- src/terminal_box.rs | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/key_bind.rs b/src/key_bind.rs index a242e42..d6774c7 100644 --- a/src/key_bind.rs +++ b/src/key_bind.rs @@ -22,8 +22,8 @@ pub struct KeyBind { } impl KeyBind { - pub fn matches(&self, modifiers: Modifiers, key: Key) -> bool { - self.key == key + pub fn matches(&self, modifiers: Modifiers, key: &Key) -> bool { + key == &self.key && modifiers.logo() == self.modifiers.contains(&Modifier::Super) && modifiers.control() == self.modifiers.contains(&Modifier::Ctrl) && modifiers.alt() == self.modifiers.contains(&Modifier::Alt) diff --git a/src/main.rs b/src/main.rs index d59a72c..e9f4a7d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1019,7 +1019,7 @@ impl Application for App { }, Message::Key(modifiers, key) => { for (key_bind, action) in self.key_binds.iter() { - if key_bind.matches(modifiers, key.clone()) { + if key_bind.matches(modifiers, &key) { return self.update(action.message(None)); } } diff --git a/src/terminal_box.rs b/src/terminal_box.rs index 8cf148a..98c5ed8 100644 --- a/src/terminal_box.rs +++ b/src/terminal_box.rs @@ -682,8 +682,7 @@ where status = Status::Captured; } Named::Space if !modifiers.control() => { - terminal - .input_scroll(format!("{}{}", alt_prefix, " ").as_bytes().to_vec()); + terminal.input_scroll(format!("{}{}", alt_prefix, " ").as_bytes().to_vec()); status = Status::Captured; } Named::Tab => {