Skip to content

Commit 88a90db

Browse files
fix change session by moving to async/await promise (#1927)
* fix change session by moving to async/await promise * add test that tests settings update
1 parent 0d992ad commit 88a90db

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/settings.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,12 @@ export function load(): ISettings {
192192
};
193193
}
194194

195-
export function change(settingName: string, newValue: any, global: boolean = false): Thenable<void> {
195+
export async function change(settingName: string, newValue: any, global: boolean = false): Promise<void> {
196196
const configuration: vscode.WorkspaceConfiguration =
197197
vscode.workspace.getConfiguration(
198198
utils.PowerShellLanguageId);
199199

200-
return configuration.update(settingName, newValue, global);
200+
await configuration.update(settingName, newValue, global);
201201
}
202202

203203
function getWorkspaceSettingsWithDefaults<TSettings>(

test/settings.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,14 @@ suite("Settings module", () => {
1919
assert.deepEqual(settings.developer.featureFlags, []);
2020
}
2121
});
22+
23+
test("Settings update correctly", async () => {
24+
// then syntax
25+
Settings.change("powerShellExePath", "dummypath1", false).then(() =>
26+
assert.strictEqual(Settings.load().powerShellExePath, "dummypath1"));
27+
28+
// async/await syntax
29+
await Settings.change("powerShellExePath", "dummypath2", false);
30+
assert.strictEqual(Settings.load().powerShellExePath, "dummypath2");
31+
});
2232
});

0 commit comments

Comments
 (0)