Skip to content

Commit 8efe4be

Browse files
authored
- Add _isFakeAction as a workaround to noop-actions that are contributed to menus but that don't do anything (microsoft#162220)
- Mark esp filtering/switching actions as fake actions microsoft#162004
1 parent c3b0ab3 commit 8efe4be

File tree

9 files changed

+24
-3
lines changed

9 files changed

+24
-3
lines changed

src/vs/platform/action/common/action.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ export interface ICommandAction {
4040
source?: string;
4141
precondition?: ContextKeyExpression;
4242
toggled?: ContextKeyExpression | { condition: ContextKeyExpression; icon?: Icon; tooltip?: string; title?: string | ILocalizedString };
43+
/** @deprecated see https://github.com/microsoft/vscode/issues/162004 */
44+
_isFakeAction?: true;
4345
}
4446

4547
export type ISerializableCommandAction = UriDto<ICommandAction>;

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,14 @@ export class WorkbenchToolBar extends ToolBar {
151151

152152
// add "hide foo" actions
153153
let hideAction: IAction;
154-
if ((action instanceof MenuItemAction || action instanceof SubmenuItemAction) && action.hideActions) {
154+
if (action instanceof MenuItemAction || action instanceof SubmenuItemAction) {
155+
if (!action.hideActions) {
156+
// no context menu for MenuItemAction instances that support no hiding
157+
// those are fake actions and need to be cleaned up
158+
return;
159+
}
155160
hideAction = action.hideActions.hide;
161+
156162
} else {
157163
hideAction = toAction({
158164
id: 'label',

src/vs/platform/actions/common/actions.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,13 @@ export interface IAction2Options extends ICommandAction {
554554
* showing keybindings that have no other UX.
555555
*/
556556
description?: ICommandHandlerDescription;
557+
558+
/**
559+
* @deprecated workaround added for https://github.com/microsoft/vscode/issues/162004
560+
* This action doesn't do anything is just a workaround for rendering "something"
561+
* inside a specific toolbar
562+
*/
563+
_isFakeAction?: true;
557564
}
558565

559566
export abstract class Action2 {

src/vs/platform/actions/common/menuService.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ class MenuInfo {
229229
const menuHide = createMenuHide(this._id, isMenuItem ? item.command : item, this._hiddenStates);
230230
if (isMenuItem) {
231231
// MenuItemAction
232-
activeActions.push(new MenuItemAction(item.command, item.alt, options, menuHide, this._contextKeyService, this._commandService));
232+
const actualMenuHide = item.command._isFakeAction ? undefined : menuHide;
233+
activeActions.push(new MenuItemAction(item.command, item.alt, options, actualMenuHide, this._contextKeyService, this._commandService));
233234

234235
} else {
235236
// SubmenuItemAction

src/vs/workbench/contrib/comments/browser/commentsViewActions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ registerAction2(class extends ViewAction<ICommentsView> {
412412
registerAction2(class extends Action2 {
413413
constructor() {
414414
super({
415+
_isFakeAction: true,
415416
id: `workbench.actions.treeView.${COMMENTS_VIEW_ID}.filter`,
416417
title: localize('filter', "Filter"),
417418
menu: {

src/vs/workbench/contrib/debug/browser/repl.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,7 @@ function getReplView(viewsService: IViewsService): Repl | undefined {
879879
registerAction2(class extends Action2 {
880880
constructor() {
881881
super({
882+
_isFakeAction: true,
882883
id: FILTER_ACTION_ID,
883884
title: localize('filter', "Filter"),
884885
f1: false,
@@ -887,7 +888,7 @@ registerAction2(class extends Action2 {
887888
group: 'navigation',
888889
when: ContextKeyExpr.equals('view', REPL_VIEW_ID),
889890
order: 10
890-
}
891+
},
891892
});
892893
}
893894

src/vs/workbench/contrib/markers/browser/markers.contribution.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ registerAction2(class extends ViewAction<IMarkersView> {
409409
registerAction2(class extends Action2 {
410410
constructor() {
411411
super({
412+
_isFakeAction: true,
412413
id: `workbench.actions.treeView.${Markers.MARKERS_VIEW_ID}.filter`,
413414
title: localize('filter', "Filter"),
414415
menu: {

src/vs/workbench/contrib/output/browser/output.contribution.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).regi
107107
registerAction2(class extends Action2 {
108108
constructor() {
109109
super({
110+
_isFakeAction: true,
110111
id: `workbench.output.action.switchBetweenOutputs`,
111112
title: nls.localize('switchToOutput.label', "Switch to Output"),
112113
menu: {

src/vs/workbench/contrib/testing/browser/testingExplorerFilter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ class FiltersDropdownMenuActionViewItem extends DropdownMenuActionViewItem {
246246
registerAction2(class extends Action2 {
247247
constructor() {
248248
super({
249+
_isFakeAction: true,
249250
id: TestCommandId.FilterAction,
250251
title: { value: localize('filter', "Filter"), original: 'Filter' },
251252
});

0 commit comments

Comments
 (0)