From 9fcd1649777543619d82dbc0d8e618304db2f09d Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Sat, 27 Apr 2019 10:31:47 -0700 Subject: [PATCH 1/2] fix change session by moving to async/await promise --- src/settings.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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( From 6dec8723f7e9bded948abb1ac0dd246f4d1d2126 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Sat, 27 Apr 2019 11:00:30 -0700 Subject: [PATCH 2/2] add test that tests settings update --- test/settings.test.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) 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"); + }); });