Skip to content

Commit ac44885

Browse files
committed
Apply environment when selecting default profile as well
Fixes microsoft#204167
1 parent 960217f commit ac44885

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/vs/workbench/contrib/terminal/browser/terminalProfileQuickpick.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ export class TerminalProfileQuickpick {
6969
if (result.profile.args) {
7070
newProfile.args = result.profile.args;
7171
}
72-
(profilesConfig as { [key: string]: ITerminalProfileObject })[result.profile.profileName] = newProfile;
72+
(profilesConfig as { [key: string]: ITerminalProfileObject })[result.profile.profileName] = this._createNewProfileConfig(result.profile);
73+
await this._configurationService.updateValue(profilesKey, profilesConfig, ConfigurationTarget.USER);
7374
}
74-
await this._configurationService.updateValue(profilesKey, profilesConfig, ConfigurationTarget.USER);
7575
}
7676
// Set the default profile
7777
await this._configurationService.updateValue(defaultProfileKey, result.profileName, ConfigurationTarget.USER);
@@ -131,14 +131,10 @@ export class TerminalProfileQuickpick {
131131
if (!name) {
132132
return;
133133
}
134-
const newConfigValue: { [key: string]: ITerminalExecutable } = { ...configProfiles };
135-
newConfigValue[name] = { path: context.item.profile.path };
136-
if (context.item.profile.args) {
137-
newConfigValue[name].args = context.item.profile.args;
138-
}
139-
if (context.item.profile.env) {
140-
newConfigValue[name].env = context.item.profile.env;
141-
}
134+
const newConfigValue: { [key: string]: ITerminalExecutable } = {
135+
...configProfiles,
136+
[name]: this._createNewProfileConfig(context.item.profile)
137+
};
142138
await this._configurationService.updateValue(profilesKey, newConfigValue, ConfigurationTarget.USER);
143139
},
144140
onKeyMods: mods => keyMods = mods
@@ -215,6 +211,17 @@ export class TerminalProfileQuickpick {
215211
return result;
216212
}
217213

214+
private _createNewProfileConfig(profile: ITerminalProfile): ITerminalExecutable {
215+
const result: ITerminalExecutable = { path: profile.path };
216+
if (profile.args) {
217+
result.args = profile.args;
218+
}
219+
if (profile.env) {
220+
result.env = profile.env;
221+
}
222+
return result;
223+
}
224+
218225
private async _isProfileSafe(profile: ITerminalProfile | IExtensionTerminalProfile): Promise<boolean> {
219226
const isUnsafePath = 'isUnsafePath' in profile && profile.isUnsafePath;
220227
const requiresUnsafePath = 'requiresUnsafePath' in profile && profile.requiresUnsafePath;

0 commit comments

Comments
 (0)