Clear plugin settings when a plugin id is re-registered (#1159)

Fixes #1116

Co-authored-by: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
NetterSilver
2026-10-24 05:24:05 -04:00
committed by GitHub
co-authored by Claude Haiku 5.5
parent 98298a3519
commit 8864e42dce
2 changed files with 11 additions and 0 deletions
+1
View File
@@ -393,6 +393,7 @@ pub(crate) fn register(s: &mut Session, entry: InstalledPlugin, wasm: Vec<u8>) -
match list.iter_mut().find(|x| x.manifest.id == id) {
Some(slot) => {
*slot = entry;
s.prefs.plugin_settings.remove(&id);
true
}
None => {
+10
View File
@@ -406,3 +406,13 @@ fn a_full_undo_history_keeps_its_steps_and_tampered_manifests_are_refused() {
s.prefs.plugins[0].manifest.main = "../../elsewhere.wasm".into();
assert!(matches!(s.execute("plugin.run", &json!({"id": "org.test.many"})), Err(EngineError::BadParams { .. })));
}
#[test]
fn reinstalling_under_an_existing_id_drops_the_old_settings() {
let mut s = Session::new();
let m = manifest("org.test.reuse", "read", &[]);
install(&mut s, m.clone(), &script(&[], OnRefusal::Fail, ""));
s.prefs.plugin_settings.entry("org.test.reuse".into()).or_default().insert("key".into(), json!("v"));
install(&mut s, m, &script(&[], OnRefusal::Fail, ""));
assert!(!s.prefs.plugin_settings.contains_key("org.test.reuse"), "{:?}", s.prefs.plugin_settings);
}