diff --git a/src/settings.ts b/src/settings.ts index dced0bb0e8..c537b3a98d 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -192,12 +192,12 @@ export function load(): ISettings { }; } -export function change(settingName: string, newValue: any, global: boolean = false): Thenable { +export async function change(settingName: string, newValue: any, global: boolean = false): Promise { const configuration: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration( utils.PowerShellLanguageId); - return configuration.update(settingName, newValue, global); + await configuration.update(settingName, newValue, global); } function getWorkspaceSettingsWithDefaults( diff --git a/test/settings.test.ts b/test/settings.test.ts index 6ff6732c99..819cfd8bbd 100644 --- a/test/settings.test.ts +++ b/test/settings.test.ts @@ -19,4 +19,14 @@ suite("Settings module", () => { assert.deepEqual(settings.developer.featureFlags, []); } }); + + test("Settings update correctly", async () => { + // then syntax + Settings.change("powerShellExePath", "dummypath1", false).then(() => + assert.strictEqual(Settings.load().powerShellExePath, "dummypath1")); + + // async/await syntax + await Settings.change("powerShellExePath", "dummypath2", false); + assert.strictEqual(Settings.load().powerShellExePath, "dummypath2"); + }); });