This commit is contained in:
meganrogge 2024-04-01 12:47:26 -07:00
parent ade21d7359
commit ae2fe7d085
No known key found for this signature in database
GPG key ID: AA74638D4878183D
2 changed files with 24 additions and 1 deletions

View file

@ -5,7 +5,7 @@
import * as dom from 'vs/base/browser/dom';
import { IActionViewItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { IAction } from 'vs/base/common/actions';
import { Action, IAction } from 'vs/base/common/actions';
import { CancellationToken } from 'vs/base/common/cancellation';
import { DropdownWithPrimaryActionViewItem } from 'vs/platform/actions/browser/dropdownWithPrimaryActionViewItem';
import { IMenu, IMenuService, MenuId, MenuItemAction } from 'vs/platform/actions/common/actions';
@ -211,6 +211,7 @@ export class TerminalEditor extends EditorPane {
if (action instanceof MenuItemAction) {
const location = { viewColumn: ACTIVE_GROUP };
const actions = getTerminalActionBarArgs(location, this._terminalProfileService.availableProfiles, this._getDefaultProfileName(), this._terminalProfileService.contributedProfiles, this._terminalService, this._dropdownMenu);
this._registerDisposableActions(actions.dropdownAction, actions.dropdownMenuActions);
const button = this._instantiationService.createInstance(DropdownWithPrimaryActionViewItem, action, actions.dropdownAction, actions.dropdownMenuActions, actions.className, this._contextMenuService, { hoverDelegate: options.hoverDelegate });
return button;
}
@ -219,6 +220,16 @@ export class TerminalEditor extends EditorPane {
return super.getActionViewItem(action, options);
}
/**
* Actions might be of type Action (disposable) or Separator or SubmenuAction, which don't extend Disposable
*/
private _registerDisposableActions(dropdownAction: IAction, dropdownMenuActions: IAction[]): void {
if (dropdownAction instanceof Action) {
this._register(dropdownAction);
}
dropdownMenuActions.filter(a => a instanceof Action).forEach(a => this._register(a));
}
private _getDefaultProfileName(): string {
let defaultProfileName;
try {

View file

@ -272,6 +272,7 @@ export class TerminalViewPane extends ViewPane {
case TerminalCommandId.New: {
if (action instanceof MenuItemAction) {
const actions = getTerminalActionBarArgs(TerminalLocation.Panel, this._terminalProfileService.availableProfiles, this._getDefaultProfileName(), this._terminalProfileService.contributedProfiles, this._terminalService, this._dropdownMenu);
this._registerDisposableActions(actions.dropdownAction, actions.dropdownMenuActions);
this._newDropdown?.dispose();
this._newDropdown = new DropdownWithPrimaryActionViewItem(action, actions.dropdownAction, actions.dropdownMenuActions, actions.className, this._contextMenuService, { hoverDelegate: options.hoverDelegate }, this._keybindingService, this._notificationService, this._contextKeyService, this._themeService, this._accessibilityService);
this._updateTabActionBar(this._terminalProfileService.availableProfiles);
@ -282,6 +283,16 @@ export class TerminalViewPane extends ViewPane {
return super.getActionViewItem(action, options);
}
/**
* Actions might be of type Action (disposable) or Separator or SubmenuAction, which don't extend Disposable
*/
private _registerDisposableActions(dropdownAction: IAction, dropdownMenuActions: IAction[]): void {
if (dropdownAction instanceof Action) {
this._register(dropdownAction);
}
dropdownMenuActions.filter(a => a instanceof Action).forEach(a => this._register(a));
}
private _getDefaultProfileName(): string {
let defaultProfileName;
try {
@ -298,6 +309,7 @@ export class TerminalViewPane extends ViewPane {
private _updateTabActionBar(profiles: ITerminalProfile[]): void {
const actions = getTerminalActionBarArgs(TerminalLocation.Panel, profiles, this._getDefaultProfileName(), this._terminalProfileService.contributedProfiles, this._terminalService, this._dropdownMenu);
this._registerDisposableActions(actions.dropdownAction, actions.dropdownMenuActions);
this._newDropdown?.update(actions.dropdownAction, actions.dropdownMenuActions);
}