Fix undo backspace on macOS

This commit is contained in:
Federico Terzi 2020-08-12 20:37:15 +02:00
parent 400d8cf9d8
commit 64dd7b9074
3 changed files with 13 additions and 7 deletions

View File

@ -152,6 +152,9 @@ fn default_global_vars() -> Vec<MatchVariable> {
fn default_modulo_path() -> Option<String> { fn default_modulo_path() -> Option<String> {
None None
} }
fn default_mac_post_inject_delay() -> u64 {
100
}
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Configs { pub struct Configs {
@ -236,6 +239,9 @@ pub struct Configs {
#[serde(default = "default_secure_input_watcher_interval")] #[serde(default = "default_secure_input_watcher_interval")]
pub secure_input_watcher_interval: i32, pub secure_input_watcher_interval: i32,
#[serde(default = "default_mac_post_inject_delay")]
pub mac_post_inject_delay: u64,
#[serde(default = "default_secure_input_notification")] #[serde(default = "default_secure_input_notification")]
pub secure_input_notification: bool, pub secure_input_notification: bool,

View File

@ -306,6 +306,13 @@ impl<
.set_clipboard(&previous_clipboard_content); .set_clipboard(&previous_clipboard_content);
} }
// On macOS, because the keyinjection is async, we need to wait a bit before
// giving back the control. Otherwise, the injected actions will be handled back
// by espanso itself.
if cfg!(target_os = "macos") {
std::thread::sleep(std::time::Duration::from_millis(config.mac_post_inject_delay));
}
// Re-allow espanso to interpret actions // Re-allow espanso to interpret actions
self.is_injecting.store(false, Release); self.is_injecting.store(false, Release);

View File

@ -106,13 +106,6 @@ impl<'a, R: MatchReceiver, M: ConfigManager<'a>> super::Matcher for ScrollingMat
.word_separators .word_separators
.contains(&c.chars().nth(0).unwrap_or_default()); .contains(&c.chars().nth(0).unwrap_or_default());
// Workaround needed on macos to consider espanso replacement key presses as separators.
if cfg!(target_os = "macos") {
if c.len() > 1 {
is_current_word_separator = true;
}
}
let mut was_previous_char_a_match = self.was_previous_char_a_match.borrow_mut(); let mut was_previous_char_a_match = self.was_previous_char_a_match.borrow_mut();
(*was_previous_char_a_match) = false; (*was_previous_char_a_match) = false;