feat(core): improve config dump when patched
This commit is contained in:
parent
e151364014
commit
7f3c70c8df
|
@ -75,7 +75,7 @@ impl ConfigStore for PatchedConfigStore {
|
|||
|
||||
// Check if a patch should be applied
|
||||
if let Some(patch) = self.patches.iter().find(|patch| (patch.should_patch)(app)) {
|
||||
(patch.apply)(active_config)
|
||||
(patch.apply)(active_config, patch.name)
|
||||
} else {
|
||||
active_config
|
||||
}
|
||||
|
|
|
@ -48,5 +48,5 @@ pub struct PatchDefinition {
|
|||
pub name: &'static str,
|
||||
pub is_enabled: fn() -> bool,
|
||||
pub should_patch: fn(app: &AppProperties) -> bool,
|
||||
pub apply: fn(config: Arc<dyn Config>) -> Arc<dyn Config>,
|
||||
pub apply: fn(config: Arc<dyn Config>, name: &str) -> Arc<dyn Config>,
|
||||
}
|
|
@ -26,14 +26,17 @@ macro_rules! generate_patchable_config {
|
|||
pub struct $struct_name {
|
||||
base: Arc<dyn Config>,
|
||||
patch: Patches,
|
||||
patched_label: String,
|
||||
}
|
||||
|
||||
impl $struct_name {
|
||||
#[allow(dead_code)]
|
||||
pub fn patch(base: Arc<dyn Config>, patch: Patches) -> Self {
|
||||
pub fn patch(base: Arc<dyn Config>, name: &str, patch: Patches) -> Self {
|
||||
let patched_label = format!("{} (PATCHED: {})", base.label(), name);
|
||||
Self {
|
||||
base,
|
||||
patch,
|
||||
patched_label,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +64,7 @@ macro_rules! generate_patchable_config {
|
|||
}
|
||||
|
||||
fn label(&self) -> &str {
|
||||
self.base.label()
|
||||
&self.patched_label
|
||||
}
|
||||
|
||||
fn match_paths(&self) -> &[String] {
|
||||
|
|
|
@ -27,9 +27,10 @@ pub fn patch() -> PatchDefinition {
|
|||
name: module_path!().split(":").last().unwrap_or("unknown"),
|
||||
is_enabled: || cfg!(target_os = "windows"),
|
||||
should_patch: |app| app.title.unwrap_or_default().contains("OneNote"),
|
||||
apply: |base| {
|
||||
apply: |base, name| {
|
||||
Arc::new(PatchedConfig::patch(
|
||||
base,
|
||||
name,
|
||||
Patches {
|
||||
key_delay: Some(Some(10)),
|
||||
..Default::default()
|
||||
|
|
Loading…
Reference in New Issue
Block a user