MCPcopy
hub / github.com/PowerShell/vscode-powershell / changeSetting

Function changeSetting

src/settings.ts:201–220  ·  view source on GitHub ↗
(
    settingName: string,
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    newValue: any,
    configurationTarget: vscode.ConfigurationTarget | boolean | undefined,
    logger: ILogger | undefined,
)

Source from the content-addressed store, hash-verified

199}
200
201export 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.
223let hasChosen = false;

Callers 7

changeCwdSettingFunction · 0.90
settings.test.tsFile · 0.90
promptToUpdateMethod · 0.90
getChosenWorkspaceFunction · 0.85

Calls 2

writeDebugMethod · 0.65
writeErrorMethod · 0.65

Tested by 1

changeCwdSettingFunction · 0.72