Skip to content

Commit

Permalink
Merge pull request #209105 from microsoft/tyriar/204167_3
Browse files Browse the repository at this point in the history
Apply environment when selecting default profile as well
  • Loading branch information
Tyriar authored Mar 29, 2024
2 parents dbb3b7b + ac44885 commit 84d8f1b
Showing 1 changed file with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ export class TerminalProfileQuickpick {
if (result.profile.args) {
newProfile.args = result.profile.args;
}
(profilesConfig as { [key: string]: ITerminalProfileObject })[result.profile.profileName] = newProfile;
(profilesConfig as { [key: string]: ITerminalProfileObject })[result.profile.profileName] = this._createNewProfileConfig(result.profile);
await this._configurationService.updateValue(profilesKey, profilesConfig, ConfigurationTarget.USER);
}
await this._configurationService.updateValue(profilesKey, profilesConfig, ConfigurationTarget.USER);
}
// Set the default profile
await this._configurationService.updateValue(defaultProfileKey, result.profileName, ConfigurationTarget.USER);
Expand Down Expand Up @@ -131,14 +131,10 @@ export class TerminalProfileQuickpick {
if (!name) {
return;
}
const newConfigValue: { [key: string]: ITerminalExecutable } = { ...configProfiles };
newConfigValue[name] = { path: context.item.profile.path };
if (context.item.profile.args) {
newConfigValue[name].args = context.item.profile.args;
}
if (context.item.profile.env) {
newConfigValue[name].env = context.item.profile.env;
}
const newConfigValue: { [key: string]: ITerminalExecutable } = {
...configProfiles,
[name]: this._createNewProfileConfig(context.item.profile)
};
await this._configurationService.updateValue(profilesKey, newConfigValue, ConfigurationTarget.USER);
},
onKeyMods: mods => keyMods = mods
Expand Down Expand Up @@ -215,6 +211,17 @@ export class TerminalProfileQuickpick {
return result;
}

private _createNewProfileConfig(profile: ITerminalProfile): ITerminalExecutable {
const result: ITerminalExecutable = { path: profile.path };
if (profile.args) {
result.args = profile.args;
}
if (profile.env) {
result.env = profile.env;
}
return result;
}

private async _isProfileSafe(profile: ITerminalProfile | IExtensionTerminalProfile): Promise<boolean> {
const isUnsafePath = 'isUnsafePath' in profile && profile.isUnsafePath;
const requiresUnsafePath = 'requiresUnsafePath' in profile && profile.requiresUnsafePath;
Expand Down

0 comments on commit 84d8f1b

Please sign in to comment.