* Search all editable settings scopes for a plugin ID matching the given input. * * If `plugin` contains `@`, it's treated as a full pluginId and returned if * found in any scope. If `plugin` is a bare name, searches for any key * starting with `{plugin}@` in any scope. * * Returns the most sp
(plugin: string)
| 178 | * Precedence: local > project > user (most specific wins). |
| 179 | */ |
| 180 | function findPluginInSettings(plugin: string): { |
| 181 | pluginId: string |
| 182 | scope: InstallableScope |
| 183 | } | null { |
| 184 | const hasMarketplace = plugin.includes('@') |
| 185 | // Most specific first — first match wins |
| 186 | const searchOrder: InstallableScope[] = ['local', 'project', 'user'] |
| 187 | |
| 188 | for (const scope of searchOrder) { |
| 189 | const enabledPlugins = getSettingsForSource( |
| 190 | scopeToSettingSource(scope), |
| 191 | )?.enabledPlugins |
| 192 | if (!enabledPlugins) continue |
| 193 | |
| 194 | for (const key of Object.keys(enabledPlugins)) { |
| 195 | if (hasMarketplace ? key === plugin : key.startsWith(`${plugin}@`)) { |
| 196 | return { pluginId: key, scope } |
| 197 | } |
| 198 | } |
| 199 | } |
| 200 | return null |
| 201 | } |
| 202 | |
| 203 | /** |
| 204 | * Helper function to find a plugin from loaded plugins |
no test coverage detected