Plug-ins: a command list read during an install is not cached under the new revision

registry::install now changes the revision while it holds the plug-in set's write lock, so a reader that sees the new revision and lists the plug-ins always finds the new one. command_specs also skips caching a list when the revision changed while it was listing. Before, a menu or shortcut lookup that ran during an install could keep the old command list until the next install or removal.
This commit is contained in:
dotCooCoo
2026-11-07 17:43:02 -08:00
parent 906fd4cfad
commit ea27cc0a2e
2 changed files with 9 additions and 2 deletions
+5
View File
@@ -324,6 +324,11 @@ pub fn command_specs() -> Vec<&'static CommandSpec> {
}
let specs: Vec<&'static CommandSpec> =
registry::list().iter().flat_map(|p| p.manifest().commands.iter().map(|c| spec_of(p, c)).collect::<Vec<_>>()).collect();
// When a plug-in was installed or removed during the listing, the list may not match
// `revision`. It is returned without being cached, and the next call lists again.
if registry::revision() != revision {
return specs;
}
let mut l = LISTED.write().unwrap_or_else(|e| e.into_inner());
if l.specs.len() != specs.len() || l.specs.iter().zip(&specs).any(|(a, b)| !std::ptr::eq(*a, *b)) {
l.generation += 1;