findPluginInSettings method

({String pluginId, PluginScope scope})? findPluginInSettings(
  1. String plugin
)

Search all editable settings scopes for a plugin ID.

Returns the most specific scope where the plugin is mentioned (local > project > user).

Implementation

({String pluginId, PluginScope scope})? findPluginInSettings(
  String plugin,
) {
  final hasMarketplace = plugin.contains('@');
  const searchOrder = [PluginScope.local, PluginScope.project, PluginScope.user];

  for (final scope in searchOrder) {
    final enabledPlugins = getSettingsEnabledPlugins(
      scopeToSettingSource(scope),
    );
    if (enabledPlugins == null) continue;

    for (final key in enabledPlugins.keys) {
      if (hasMarketplace ? key == plugin : key.startsWith('$plugin@')) {
        return (pluginId: key, scope: scope);
      }
    }
  }
  return null;
}