Clean up empty plugin lists from _nonGlobalPlugins

After removing plugins, also remove dictionary entries if their
associated lists become empty. This prevents unused empty lists
from accumulating and keeps the plugin manager's state clean.
This commit is contained in:
Jack251970 2026-02-26 17:19:36 +08:00
parent 2529efeed1
commit 4537013cde

View file

@ -816,6 +816,11 @@ namespace Flow.Launcher.Core.Plugin
lock (plugins)
{
plugins.RemoveAll(p => p.Metadata.ID == id);
if (plugins.Count == 0)
{
_nonGlobalPlugins.TryRemove(new KeyValuePair<string, List<PluginPair>>(oldActionkeyword, plugins));
}
}
}
}
@ -1081,6 +1086,11 @@ namespace Flow.Launcher.Core.Plugin
lock (entry.Value)
{
entry.Value.RemoveAll(p => p.Metadata.ID == plugin.ID);
if (entry.Value.Count == 0)
{
_nonGlobalPlugins.TryRemove(entry.Key, out var __);
}
}
}
}