Skip to content

Commit

Permalink
layout - show keybindings in picker (fix #143669) (#199512)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero authored Dec 21, 2023
1 parent 8a45b1b commit 30b7773
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/vs/workbench/browser/actions/layoutActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { DisposableStore } from 'vs/base/common/lifecycle';
import { registerIcon } from 'vs/platform/theme/common/iconRegistry';
import { ICommandActionTitle } from 'vs/platform/action/common/action';
import { mainWindow } from 'vs/base/browser/window';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';

// Register Icons
const menubarIcon = registerIcon('menuBar', Codicon.layoutMenubar, localize('menuBarIcon', "Represents the menu bar"));
Expand Down Expand Up @@ -1422,7 +1423,7 @@ registerAction2(class CustomizeLayoutAction extends Action2 {
});
}

getItems(contextKeyService: IContextKeyService): QuickPickItem[] {
getItems(contextKeyService: IContextKeyService, keybindingService: IKeybindingService): QuickPickItem[] {
const toQuickPickItem = (item: CustomizeLayoutItem): IQuickPickItem => {
const toggled = item.active.evaluate(contextKeyService.getContext(null));
let label = item.useButtons ?
Expand All @@ -1448,6 +1449,7 @@ registerAction2(class CustomizeLayoutAction extends Action2 {
id: item.id,
label,
ariaLabel,
keybinding: keybindingService.lookupKeybinding(item.id, contextKeyService),
buttons: !item.useButtons ? undefined : [
{
alwaysVisible: false,
Expand Down Expand Up @@ -1491,10 +1493,11 @@ registerAction2(class CustomizeLayoutAction extends Action2 {
const contextKeyService = accessor.get(IContextKeyService);
const commandService = accessor.get(ICommandService);
const quickInputService = accessor.get(IQuickInputService);
const keybindingService = accessor.get(IKeybindingService);
const quickPick = quickInputService.createQuickPick();

this._currentQuickPick = quickPick;
quickPick.items = this.getItems(contextKeyService);
quickPick.items = this.getItems(contextKeyService, keybindingService);
quickPick.ignoreFocusOut = true;
quickPick.hideInput = true;
quickPick.title = localize('customizeLayoutQuickPickTitle', "Customize Layout");
Expand All @@ -1520,7 +1523,7 @@ registerAction2(class CustomizeLayoutAction extends Action2 {
let selectedItem: CustomizeLayoutItem | undefined = undefined;
disposables.add(contextKeyService.onDidChangeContext(changeEvent => {
if (changeEvent.affectsSome(LayoutContextKeySet)) {
quickPick.items = this.getItems(contextKeyService);
quickPick.items = this.getItems(contextKeyService, keybindingService);
if (selectedItem) {
quickPick.activeItems = quickPick.items.filter(item => (item as CustomizeLayoutItem).id === selectedItem?.id) as IQuickPickItem[];
}
Expand Down

0 comments on commit 30b7773

Please sign in to comment.