Skip to content

Commit

Permalink
Some menu action clients (ActionBar) handle alternative actions on th…
Browse files Browse the repository at this point in the history
…eir own so the alternative actions should be ignored

fixes #50581
  • Loading branch information
isidorn committed May 31, 2018
1 parent 035f2e8 commit 172309c
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/vs/platform/actions/browser/menuItemActionItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function fillInActions(menu: IMenu, options: IMenuActionOptions, target:
if (groups.length === 0) {
return;
}
const getAlternativeActions = AlternativeKeyEmitter.getInstance(contextMenuService).isPressed;
const getAlternativeActions = (!options || !options.ignoreAlternativeActions) && AlternativeKeyEmitter.getInstance(contextMenuService).isPressed;

for (let tuple of groups) {
let [group, actions] = tuple;
Expand Down
2 changes: 2 additions & 0 deletions src/vs/platform/actions/common/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export class MenuId {
export interface IMenuActionOptions {
arg?: any;
shouldForwardArgs?: boolean;
// Some menu action clients (ActionBar) handle alternative actions on their own so the alternative actions should be ignored
ignoreAlternativeActions?: boolean;
}

export interface IMenu extends IDisposable {
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/browser/parts/editor/titleControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export abstract class TitleControl extends Themable {
this.updateEditorActionsToolbar();
}));

fillInActions(titleBarMenu, { arg: this.resourceContext.get(), shouldForwardArgs: true }, { primary, secondary }, this.contextMenuService);
fillInActions(titleBarMenu, { arg: this.resourceContext.get(), shouldForwardArgs: true, ignoreAlternativeActions: true }, { primary, secondary }, this.contextMenuService);
}

return { primary, secondary };
Expand Down Expand Up @@ -344,4 +344,4 @@ registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => {
color: ${dragImageForeground};
}
`);
});
});
4 changes: 2 additions & 2 deletions src/vs/workbench/browser/parts/views/customViewPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class Menus implements IDisposable {
const updateActions = () => {
this.titleActions = [];
this.titleSecondaryActions = [];
fillInActions(titleMenu, null, { primary: this.titleActions, secondary: this.titleSecondaryActions }, this.contextMenuService);
fillInActions(titleMenu, { ignoreAlternativeActions: true }, { primary: this.titleActions, secondary: this.titleSecondaryActions }, this.contextMenuService);
this._onDidChangeTitle.fire();
};

Expand All @@ -144,4 +144,4 @@ export class Menus implements IDisposable {
dispose(): void {
this.disposables = dispose(this.disposables);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class DirtyDiffWidget extends PeekViewWidget {
this._actionbarWidget.push([previous, next], { label: false, icon: true });

const actions: IAction[] = [];
fillInActions(this.menu, { shouldForwardArgs: true }, actions, this.contextMenuService);
fillInActions(this.menu, { shouldForwardArgs: true, ignoreAlternativeActions: true }, actions, this.contextMenuService);
this._actionbarWidget.push(actions, { label: false, icon: true });
}

Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/parts/scm/electron-browser/scmMenus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class SCMMenus implements IDisposable {
this.titleActions = [];
this.titleSecondaryActions = [];
// TODO@joao: second arg used to be null
fillInActions(this.titleMenu, { shouldForwardArgs: true }, { primary: this.titleActions, secondary: this.titleSecondaryActions }, this.contextMenuService);
fillInActions(this.titleMenu, { shouldForwardArgs: true, ignoreAlternativeActions: true }, { primary: this.titleActions, secondary: this.titleSecondaryActions }, this.contextMenuService);
this._onDidChangeTitle.fire();
}

Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ class ResourceGroupRenderer implements IRenderer<ISCMResourceGroup, ResourceGrou
const primary: IAction[] = [];
const secondary: IAction[] = [];
const result = { primary, secondary };
fillInActions(menu, { shouldForwardArgs: true }, result, this.contextMenuService, g => /^inline/.test(g));
fillInActions(menu, { shouldForwardArgs: true, ignoreAlternativeActions: true }, result, this.contextMenuService, g => /^inline/.test(g));

template.actionBar.clear();
template.actionBar.push(primary, { icon: true, label: false });
Expand Down Expand Up @@ -537,7 +537,7 @@ class ResourceRenderer implements IRenderer<ISCMResource, ResourceTemplate> {
const primary: IAction[] = [];
const secondary: IAction[] = [];
const result = { primary, secondary };
fillInActions(menu, { shouldForwardArgs: true }, result, this.contextMenuService, g => /^inline/.test(g));
fillInActions(menu, { shouldForwardArgs: true, ignoreAlternativeActions: true }, result, this.contextMenuService, g => /^inline/.test(g));

template.actionBar.clear();
template.actionBar.push(primary, { icon: true, label: false });
Expand Down

0 comments on commit 172309c

Please sign in to comment.