Apply environment when selecting default profile as well

Fixes #204167
This commit is contained in:
Daniel Imms 2024-03-29 06:23:28 -07:00
parent 960217faf7
commit ac44885672
No known key found for this signature in database
GPG key ID: E5CF412B63651C69

View file

@ -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);
@ -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
@ -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;