diff --git a/src/plugin.rs b/src/plugin.rs index ea6361a8..6c0eae58 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -326,7 +326,7 @@ impl PluginManager { } if let Some(map) = enabled_caps { if let Some(caps) = map.get(name) { - if !caps.contains(&"search".to_string()) { + if !caps.iter().any(|c| c == "search") { continue; } } diff --git a/tests/plugin_routing.rs b/tests/plugin_routing.rs index 81c8ee0b..80b8f756 100644 --- a/tests/plugin_routing.rs +++ b/tests/plugin_routing.rs @@ -128,6 +128,28 @@ fn global_plugins_and_opt_out_plugins_still_run() { assert_eq!(prefixed_calls.load(Ordering::SeqCst), 0); } +#[test] +fn search_capability_gate_skips_plugin_when_disabled() { + use std::collections::HashMap; + + let calls = Arc::new(AtomicUsize::new(0)); + + let mut pm = PluginManager::new(); + pm.register(Box::new(CountingPlugin::new( + "searchable", + &[], + false, + calls.clone(), + ))); + + let mut enabled_caps = HashMap::new(); + enabled_caps.insert("searchable".to_string(), vec!["commands".to_string()]); + + let out = pm.search_filtered("query", None, Some(&enabled_caps)); + assert!(out.is_empty()); + assert_eq!(calls.load(Ordering::SeqCst), 0); +} + #[test] fn existing_prefix_commands_remain_equivalent() { let plugin = TodoPlugin::default();