Skip to content

Commit e3155b6

Browse files
authored
add task section to terminal dropdown (microsoft#165553)
1 parent d0cb883 commit e3155b6

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed

src/vs/platform/actions/browser/dropdownWithPrimaryActionViewItem.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class DropdownWithPrimaryActionViewItem extends BaseActionViewItem {
4949
this._primaryAction = new MenuEntryActionViewItem(primaryAction, undefined, _keybindingService, _notificationService, _contextKeyService, _themeService, _contextMenuProvider);
5050
this._dropdown = new DropdownMenuActionViewItem(dropdownAction, dropdownMenuActions, this._contextMenuProvider, {
5151
menuAsChild: true,
52-
classNames: ['codicon', 'codicon-chevron-down'],
52+
classNames: ['codicon', 'codicon-chevron-down', className],
5353
keybindingProvider: this._options?.getKeyBinding
5454
});
5555
}

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

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { IMenu, MenuId, MenuRegistry } from 'vs/platform/actions/common/actions'
1111
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
1212
import { IExtensionTerminalProfile, ITerminalProfile, TerminalLocation, TerminalSettingId } from 'vs/platform/terminal/common/terminal';
1313
import { ResourceContextKey } from 'vs/workbench/common/contextkeys';
14+
import { TaskExecutionSupportedContext } from 'vs/workbench/contrib/tasks/common/taskService';
1415
import { ICreateTerminalOptions, ITerminalLocationOptions, ITerminalService } from 'vs/workbench/contrib/terminal/browser/terminal';
1516
import { TerminalCommandId, TERMINAL_VIEW_ID } from 'vs/workbench/contrib/terminal/common/terminal';
1617
import { TerminalContextKeys, TerminalContextKeyStrings } from 'vs/workbench/contrib/terminal/common/terminalContextKey';
@@ -25,12 +26,6 @@ const enum ContextMenuGroup {
2526
Config = '5_config'
2627
}
2728

28-
export const enum TerminalTabContextMenuGroup {
29-
Default = '1_create_default',
30-
Profile = '2_create_profile',
31-
Configure = '3_configure'
32-
}
33-
3429
export const enum TerminalMenuBarGroup {
3530
Create = '1_create',
3631
Run = '2_run',
@@ -334,9 +329,9 @@ export function setupTerminalMenus(): void {
334329
item: {
335330
command: {
336331
id: TerminalCommandId.SelectDefaultProfile,
337-
title: { value: localize('workbench.action.terminal.selectDefaultProfile', "Select Default Profile"), original: 'Select Default Profile' }
332+
title: { value: localize('workbench.action.terminal.selectDefaultProfile', "Select Default Profile"), original: 'Select Default Profile' },
338333
},
339-
group: TerminalTabContextMenuGroup.Configure
334+
group: '3_configure'
340335
}
341336
},
342337
{
@@ -346,8 +341,32 @@ export function setupTerminalMenus(): void {
346341
id: TerminalCommandId.ConfigureTerminalSettings,
347342
title: localize('workbench.action.terminal.openSettings', "Configure Terminal Settings")
348343
},
349-
group: TerminalTabContextMenuGroup.Configure
344+
group: '3_configure'
350345
}
346+
},
347+
{
348+
id: MenuId.TerminalNewDropdownContext,
349+
item: {
350+
command: {
351+
id: 'workbench.action.tasks.runTask',
352+
title: localize('workbench.action.tasks.runTask', "Run Task...")
353+
},
354+
when: TaskExecutionSupportedContext,
355+
group: '4_tasks',
356+
order: 1
357+
},
358+
},
359+
{
360+
id: MenuId.TerminalNewDropdownContext,
361+
item: {
362+
command: {
363+
id: 'workbench.action.tasks.configureTaskRunner',
364+
title: localize('workbench.action.tasks.configureTaskRunner', "Configure Tasks...")
365+
},
366+
when: TaskExecutionSupportedContext,
367+
group: '4_tasks',
368+
order: 2
369+
},
351370
}
352371
]
353372
);
@@ -797,15 +816,8 @@ export function getTerminalActionBarArgs(location: ITerminalLocationOptions, pro
797816
dropdownActions.push(new SubmenuAction('split.profile', localize('splitTerminal', 'Split Terminal'), submenuActions));
798817
dropdownActions.push(new Separator());
799818
}
800-
801-
for (const [, configureActions] of dropdownMenu.getActions()) {
802-
for (const action of configureActions) {
803-
// make sure the action is a MenuItemAction
804-
if ('alt' in action) {
805-
dropdownActions.push(action);
806-
}
807-
}
808-
}
819+
const actions = dropdownMenu.getActions();
820+
dropdownActions.push(...Separator.join(...actions.map(a => a[1])));
809821

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

0 commit comments

Comments
 (0)