Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add task section to terminal dropdown #165553

Merged
merged 3 commits into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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