From 92e49b4d6554615bbd54c3c5ebe80401066a7efa Mon Sep 17 00:00:00 2001 From: Federico Terzi Date: Sat, 2 May 2020 14:31:28 +0200 Subject: [PATCH] Fix #252 on macOS. --- src/context/macos.rs | 1 + src/event/mod.rs | 3 +++ src/matcher/scrolling.rs | 8 +++++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/context/macos.rs b/src/context/macos.rs index 7a71d25..48641a1 100644 --- a/src/context/macos.rs +++ b/src/context/macos.rs @@ -194,6 +194,7 @@ extern fn keypress_callback(_self: *mut c_void, raw_buffer: *const u8, len: i32, 0x3B => Some(LEFT_CTRL), 0x3E => Some(RIGHT_CTRL), 0x33 => Some(BACKSPACE), + 0x39 => Some(CAPS_LOCK), _ => None, }; diff --git a/src/event/mod.rs b/src/event/mod.rs index 53f901d..0ecd542 100644 --- a/src/event/mod.rs +++ b/src/event/mod.rs @@ -79,6 +79,9 @@ pub enum KeyModifier { RIGHT_META, LEFT_SHIFT, RIGHT_SHIFT, + + // Special cases, should not be used in config + CAPS_LOCK, } impl KeyModifier { diff --git a/src/matcher/scrolling.rs b/src/matcher/scrolling.rs index 6b43794..1916b9c 100644 --- a/src/matcher/scrolling.rs +++ b/src/matcher/scrolling.rs @@ -21,7 +21,7 @@ use crate::matcher::{Match, MatchReceiver, TriggerEntry}; use std::cell::{RefCell}; use crate::event::{KeyModifier, ActionEventReceiver, ActionType}; use crate::config::ConfigManager; -use crate::event::KeyModifier::BACKSPACE; +use crate::event::KeyModifier::{BACKSPACE, LEFT_SHIFT, RIGHT_SHIFT, CAPS_LOCK}; use std::time::SystemTime; use std::collections::VecDeque; @@ -237,8 +237,10 @@ impl <'a, R: MatchReceiver, M: ConfigManager<'a>> super::Matcher for ScrollingMa } // Consider modifiers as separators to improve word matches reliability - let mut was_previous_char_word_separator = self.was_previous_char_word_separator.borrow_mut(); - *was_previous_char_word_separator = true; + if m != LEFT_SHIFT && m != RIGHT_SHIFT && m != CAPS_LOCK { + let mut was_previous_char_word_separator = self.was_previous_char_word_separator.borrow_mut(); + *was_previous_char_word_separator = true; + } } fn handle_other(&self) {