diff --git a/espanso-config/src/config/mod.rs b/espanso-config/src/config/mod.rs index 784c8b3..6304f4a 100644 --- a/espanso-config/src/config/mod.rs +++ b/espanso-config/src/config/mod.rs @@ -103,6 +103,9 @@ pub trait Config: Send + Sync { // are typed. fn backspace_limit(&self) -> usize; + // If false, avoid applying the built-in patches to the current config. + fn apply_patch(&self) -> bool; + fn is_match<'a>(&self, app: &AppProperties<'a>) -> bool; } diff --git a/espanso-config/src/config/parse/mod.rs b/espanso-config/src/config/parse/mod.rs index a1615e2..d7507f9 100644 --- a/espanso-config/src/config/parse/mod.rs +++ b/espanso-config/src/config/parse/mod.rs @@ -36,6 +36,7 @@ pub(crate) struct ParsedConfig { pub disable_x11_fast_inject: Option, pub word_separators: Option>, pub backspace_limit: Option, + pub apply_patch: Option, pub pre_paste_delay: Option, pub restore_clipboard_delay: Option, diff --git a/espanso-config/src/config/parse/yaml.rs b/espanso-config/src/config/parse/yaml.rs index 67af459..5c30bcf 100644 --- a/espanso-config/src/config/parse/yaml.rs +++ b/espanso-config/src/config/parse/yaml.rs @@ -75,6 +75,9 @@ pub(crate) struct YAMLConfig { #[serde(default)] pub backspace_limit: Option, + #[serde(default)] + pub apply_patch: Option, + // Include/Exclude #[serde(default)] pub includes: Option>, @@ -135,6 +138,7 @@ impl TryFrom for ParsedConfig { key_delay: yaml_config.key_delay.or(yaml_config.backspace_delay), word_separators: yaml_config.word_separators, backspace_limit: yaml_config.backspace_limit, + apply_patch: yaml_config.apply_patch, pre_paste_delay: yaml_config.pre_paste_delay, restore_clipboard_delay: yaml_config.restore_clipboard_delay, @@ -211,6 +215,7 @@ mod tests { inject_delay: Some(10), key_delay: Some(20), backspace_limit: Some(10), + apply_patch: Some(false), pre_paste_delay: Some(300), diff --git a/espanso-config/src/config/resolve.rs b/espanso-config/src/config/resolve.rs index ab8a158..4c0980b 100644 --- a/espanso-config/src/config/resolve.rs +++ b/espanso-config/src/config/resolve.rs @@ -247,6 +247,10 @@ impl Config for ResolvedConfig { fn backspace_limit(&self) -> usize { self.parsed.backspace_limit.unwrap_or(5) } + + fn apply_patch(&self) -> bool { + self.parsed.apply_patch.unwrap_or(true) + } } impl ResolvedConfig { @@ -310,6 +314,7 @@ impl ResolvedConfig { preserve_clipboard, restore_clipboard_delay, paste_shortcut, + apply_patch, paste_shortcut_event_delay, disable_x11_fast_inject, toggle_key, diff --git a/espanso-config/src/legacy/mod.rs b/espanso-config/src/legacy/mod.rs index 5d43bdf..f142cbe 100644 --- a/espanso-config/src/legacy/mod.rs +++ b/espanso-config/src/legacy/mod.rs @@ -339,6 +339,10 @@ impl Config for LegacyInteropConfig { fn backspace_limit(&self) -> usize { self.config.backspace_limit.try_into().unwrap() } + + fn apply_patch(&self) -> bool { + true + } } struct LegacyMatchGroup {