feat(core): wire up apply_patch option

This commit is contained in:
Federico Terzi 2021-07-31 17:17:47 +02:00
parent 4504977384
commit 90db84b92f
2 changed files with 6 additions and 1 deletions

View File

@ -69,6 +69,10 @@ impl ConfigStore for PatchedConfigStore {
fn active<'f>(&'f self, app: &espanso_config::config::AppProperties) -> Arc<dyn Config> { fn active<'f>(&'f self, app: &espanso_config::config::AppProperties) -> Arc<dyn Config> {
let active_config = self.config_store.active(app); let active_config = self.config_store.active(app);
if !active_config.apply_patch() {
return active_config;
}
// Check if a patch should be applied // Check if a patch should be applied
if let Some(patch) = self.patches.iter().find(|patch| (patch.should_patch)(app)) { if let Some(patch) = self.patches.iter().find(|patch| (patch.should_patch)(app)) {
(patch.apply)(active_config) (patch.apply)(active_config)

View File

@ -40,5 +40,6 @@ generate_patchable_config!(
inject_delay -> Option<usize>, inject_delay -> Option<usize>,
key_delay -> Option<usize>, key_delay -> Option<usize>,
word_separators -> Vec<String>, word_separators -> Vec<String>,
backspace_limit -> usize backspace_limit -> usize,
apply_patch -> bool
); );