diff --git a/src/extension.ts b/src/extension.ts index 59da08a..25209ec 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -13,7 +13,7 @@ async function activateProfile( ) { let msg = vscode.window.setStatusBarMessage("Switching profiles."); - config.setCurrentProfile(profile); + await config.setCurrentProfile(profile); let profileSettings = config.getProfileSettings(profile); await settingsHelper.updateUserSettings(profileSettings); diff --git a/src/services/config.ts b/src/services/config.ts index 4680c7b..d297e41 100755 --- a/src/services/config.ts +++ b/src/services/config.ts @@ -42,12 +42,12 @@ class Config { return config.update(ConfigLiveShareProfileKey, profile, vscode.ConfigurationTarget.Global); } - public setCurrentProfile(profile: string) { + public async setCurrentProfile(profile: string) { if (this.context) { const previousProfile = this.context.globalState.get(ContextSettingCurrentProfile); this.setPreviousProfile(previousProfile); - this.context.globalState.update(ContextSettingCurrentProfile, profile); + await this.context.globalState.update(ContextSettingCurrentProfile, profile); } } diff --git a/src/services/liveShare.ts b/src/services/liveShare.ts index bcbaa78..19397b7 100644 --- a/src/services/liveShare.ts +++ b/src/services/liveShare.ts @@ -12,17 +12,12 @@ export async function initialize( return; } - const liveShareProfile = config.getLiveShareProfile(); - if (!liveShareProfile) { - return; - } - - // Check to see whether there was a lingering profile set - // (e.g. because the user closed VS Code while in a Live Share - // session), and if so, restore the right profile. - restorePreviousProfile(config, activateProfileHandler); - liveShare.onDidChangeSession(e => { + const liveShareProfile = config.getLiveShareProfile(); + if (!liveShareProfile) { + return; + } + if (e.session.id) { activateProfileHandler(liveShareProfile); } else {