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> {
None
}
fn default_mac_post_inject_delay() -> u64 {
100
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Configs {
@ -236,6 +239,9 @@ pub struct Configs {
#[serde(default = "default_secure_input_watcher_interval")]
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")]
pub secure_input_notification: bool,

View File

@ -306,6 +306,13 @@ impl<
.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
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
.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();
(*was_previous_char_a_match) = false;