Skip to content

Commit

Permalink
add task section to terminal dropdown (#165553)
Browse files Browse the repository at this point in the history
  • Loading branch information
meganrogge authored Nov 4, 2022
1 parent d0cb883 commit e3155b6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class DropdownWithPrimaryActionViewItem extends BaseActionViewItem {
this._primaryAction = new MenuEntryActionViewItem(primaryAction, undefined, _keybindingService, _notificationService, _contextKeyService, _themeService, _contextMenuProvider);
this._dropdown = new DropdownMenuActionViewItem(dropdownAction, dropdownMenuActions, this._contextMenuProvider, {
menuAsChild: true,
classNames: ['codicon', 'codicon-chevron-down'],
classNames: ['codicon', 'codicon-chevron-down', className],
keybindingProvider: this._options?.getKeyBinding
});
}
Expand Down
48 changes: 30 additions & 18 deletions src/vs/workbench/contrib/terminal/browser/terminalMenus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { IMenu, MenuId, MenuRegistry } from 'vs/platform/actions/common/actions'
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { IExtensionTerminalProfile, ITerminalProfile, TerminalLocation, TerminalSettingId } from 'vs/platform/terminal/common/terminal';
import { ResourceContextKey } from 'vs/workbench/common/contextkeys';
import { TaskExecutionSupportedContext } from 'vs/workbench/contrib/tasks/common/taskService';
import { ICreateTerminalOptions, ITerminalLocationOptions, ITerminalService } from 'vs/workbench/contrib/terminal/browser/terminal';
import { TerminalCommandId, TERMINAL_VIEW_ID } from 'vs/workbench/contrib/terminal/common/terminal';
import { TerminalContextKeys, TerminalContextKeyStrings } from 'vs/workbench/contrib/terminal/common/terminalContextKey';
Expand All @@ -25,12 +26,6 @@ const enum ContextMenuGroup {
Config = '5_config'
}

export const enum TerminalTabContextMenuGroup {
Default = '1_create_default',
Profile = '2_create_profile',
Configure = '3_configure'
}

export const enum TerminalMenuBarGroup {
Create = '1_create',
Run = '2_run',
Expand Down Expand Up @@ -334,9 +329,9 @@ export function setupTerminalMenus(): void {
item: {
command: {
id: TerminalCommandId.SelectDefaultProfile,
title: { value: localize('workbench.action.terminal.selectDefaultProfile', "Select Default Profile"), original: 'Select Default Profile' }
title: { value: localize('workbench.action.terminal.selectDefaultProfile', "Select Default Profile"), original: 'Select Default Profile' },
},
group: TerminalTabContextMenuGroup.Configure
group: '3_configure'
}
},
{
Expand All @@ -346,8 +341,32 @@ export function setupTerminalMenus(): void {
id: TerminalCommandId.ConfigureTerminalSettings,
title: localize('workbench.action.terminal.openSettings', "Configure Terminal Settings")
},
group: TerminalTabContextMenuGroup.Configure
group: '3_configure'
}
},
{
id: MenuId.TerminalNewDropdownContext,
item: {
command: {
id: 'workbench.action.tasks.runTask',
title: localize('workbench.action.tasks.runTask', "Run Task...")
},
when: TaskExecutionSupportedContext,
group: '4_tasks',
order: 1
},
},
{
id: MenuId.TerminalNewDropdownContext,
item: {
command: {
id: 'workbench.action.tasks.configureTaskRunner',
title: localize('workbench.action.tasks.configureTaskRunner', "Configure Tasks...")
},
when: TaskExecutionSupportedContext,
group: '4_tasks',
order: 2
},
}
]
);
Expand Down Expand Up @@ -797,15 +816,8 @@ export function getTerminalActionBarArgs(location: ITerminalLocationOptions, pro
dropdownActions.push(new SubmenuAction('split.profile', localize('splitTerminal', 'Split Terminal'), submenuActions));
dropdownActions.push(new Separator());
}

for (const [, configureActions] of dropdownMenu.getActions()) {
for (const action of configureActions) {
// make sure the action is a MenuItemAction
if ('alt' in action) {
dropdownActions.push(action);
}
}
}
const actions = dropdownMenu.getActions();
dropdownActions.push(...Separator.join(...actions.map(a => a[1])));

const defaultSubmenuProfileAction = submenuActions.find(d => d.label.endsWith('(Default)'));
if (defaultSubmenuProfileAction) {
Expand Down

0 comments on commit e3155b6

Please sign in to comment.