Skip to content

Commit

Permalink
fix #120037
Browse files Browse the repository at this point in the history
  • Loading branch information
meganrogge committed Mar 30, 2021
1 parent 9fd5f25 commit e94d7fe
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/terminal/browser/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export interface ITerminalService {
*/
registerLinkProvider(linkProvider: ITerminalExternalLinkProvider): IDisposable;

selectDefaultProfile(): Promise<void>;
selectDefaultProfile(quickCreate?: boolean): Promise<void>;

/**
* Gets the detected terminal profiles for the platform
Expand Down
13 changes: 13 additions & 0 deletions src/vs/workbench/contrib/terminal/browser/terminalActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,19 @@ export function registerTerminalActions() {
await terminalService.showPanel(true);
}
});
registerAction2(class extends Action2 {
constructor() {
super({
id: TERMINAL_COMMAND_ID.NEW_WITH_PROFILE,
title: { value: localize('workbench.action.terminal.newWithProfile', "Create New Integrated Terminal With Profile"), original: 'Create New Integrated Terminal With Profile' },
f1: true,
category,
});
}
async run(accessor: ServicesAccessor) {
await accessor.get(ITerminalService).selectDefaultProfile(true);
}
});
registerAction2(class extends Action2 {
constructor() {
super({
Expand Down
23 changes: 15 additions & 8 deletions src/vs/workbench/contrib/terminal/browser/terminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -842,12 +842,12 @@ export class TerminalService implements ITerminalService {
return isWindows ? 'windows' : (isMacintosh ? 'osx' : 'linux');
}

public async selectDefaultProfile(): Promise<void> {
public async selectDefaultProfile(quickCreate?: boolean): Promise<void> {
const profiles = await this._detectProfiles(false);
const platformKey = await this._getPlatformKey();

const options: IPickOptions<IProfileQuickPickItem> = {
placeHolder: nls.localize('terminal.integrated.chooseWindowsShell', "Select your default terminal profile"),
placeHolder: quickCreate ? nls.localize('terminal.integrated.chooseQuickCreateProfile', "Select the terminal profile to create") : nls.localize('terminal.integrated.chooseDefaultProfile', "Select your default terminal profile"),
onDidTriggerItemButton: async (context) => {
const configKey = `terminal.integrated.profiles.${platformKey}`;
const configProfiles = this._configurationService.inspect<{ [key: string]: ITerminalProfileObject }>(configKey);
Expand Down Expand Up @@ -880,23 +880,30 @@ export class TerminalService implements ITerminalService {
const autoDetectedProfiles = profiles.filter(e => e.isAutoDetected);
if (configProfiles.length > 0) {
quickPickItems.push({ type: 'separator', label: nls.localize('terminalProfiles', "profiles") });
quickPickItems.push(...configProfiles.map(e => this._createProfileQuickPickItem(e)));
quickPickItems.push(...configProfiles.map(e => this._createProfileQuickPickItem(e, quickCreate)));
}
if (configProfiles.length > 0) {
quickPickItems.push({ type: 'separator', label: nls.localize('terminalProfiles.detected', "detected") });
quickPickItems.push(...autoDetectedProfiles.map(e => this._createProfileQuickPickItem(e)));
quickPickItems.push(...autoDetectedProfiles.map(e => this._createProfileQuickPickItem(e, quickCreate)));
}

const value = await this._quickInputService.pick(quickPickItems, options);
if (!value) {
return;
}
await this._configurationService.updateValue(`terminal.integrated.shell.${platformKey}`, value.profile.path, ConfigurationTarget.USER);
await this._configurationService.updateValue(`terminal.integrated.shellArgs.${platformKey}`, value.profile.args, ConfigurationTarget.USER);
const profile = autoDetectedProfiles.find(profile => profile.profileName === value.profile.profileName) || configProfiles.find(profile => profile.profileName === value.profile.profileName);
if (quickCreate && profile) {
const instance = this.createTerminal({ executable: profile.path, args: profile.args, name: profile.overrideName ? profile.profileName : undefined });
this.showPanel(true);
this.setActiveInstance(instance);
} else {
await this._configurationService.updateValue(`terminal.integrated.shell.${platformKey}`, value.profile.path, ConfigurationTarget.USER);
await this._configurationService.updateValue(`terminal.integrated.shellArgs.${platformKey}`, value.profile.args, ConfigurationTarget.USER);
}
}

private _createProfileQuickPickItem(profile: ITerminalProfile): IProfileQuickPickItem {
const buttons: IQuickInputButton[] = [{
private _createProfileQuickPickItem(profile: ITerminalProfile, quickCreate?: boolean): IProfileQuickPickItem {
const buttons: IQuickInputButton[] = quickCreate ? [] : [{
iconClass: ThemeIcon.asClassName(configureTerminalProfileIcon),
tooltip: nls.localize('createQuickLaunchProfile', "Configure Terminal Profile")
}];
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/contrib/terminal/common/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ export const enum TERMINAL_COMMAND_ID {
NEW_WITH_CWD = 'workbench.action.terminal.newWithCwd',
NEW_LOCAL = 'workbench.action.terminal.newLocal',
NEW_IN_ACTIVE_WORKSPACE = 'workbench.action.terminal.newInActiveWorkspace',
NEW_WITH_PROFILE = 'workbench.action.terminal.newWithProfile',
SPLIT = 'workbench.action.terminal.split',
SPLIT_IN_ACTIVE_WORKSPACE = 'workbench.action.terminal.splitInActiveWorkspace',
RELAUNCH = 'workbench.action.terminal.relaunch',
Expand Down

0 comments on commit e94d7fe

Please sign in to comment.