| 199 | } |
| 200 | |
| 201 | export async function changeSetting( |
| 202 | settingName: string, |
| 203 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 204 | newValue: any, |
| 205 | configurationTarget: vscode.ConfigurationTarget | boolean | undefined, |
| 206 | logger: ILogger | undefined, |
| 207 | ): Promise<void> { |
| 208 | logger?.writeDebug( |
| 209 | `Changing '${settingName}' at scope '${configurationTarget}' to '${newValue}'.`, |
| 210 | ); |
| 211 | |
| 212 | try { |
| 213 | const configuration = vscode.workspace.getConfiguration( |
| 214 | utils.PowerShellLanguageId, |
| 215 | ); |
| 216 | await configuration.update(settingName, newValue, configurationTarget); |
| 217 | } catch (err) { |
| 218 | logger?.writeError(`Failed to change setting: ${err}`); |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | // We don't want to query the user more than once, so this is idempotent. |
| 223 | let hasChosen = false; |