Skip to content

Commit

Permalink
better keybinding rendering in suggest status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Jun 30, 2021
1 parent b64c52b commit 84323a8
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/vs/editor/contrib/suggest/suggestWidgetStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,22 @@ import { MenuEntryActionViewItem } from 'vs/platform/actions/browser/menuEntryAc
import { IMenuService, MenuItemAction } from 'vs/platform/actions/common/actions';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { INotificationService } from 'vs/platform/notification/common/notification';

class StatusBarViewItem extends MenuEntryActionViewItem {

constructor(
action: MenuItemAction,
@IKeybindingService keybindingService: IKeybindingService,
@INotificationService notificationService: INotificationService,
@IContextKeyService private _contextKeyService: IContextKeyService,
) {
super(action, undefined, keybindingService, notificationService);
}

override updateLabel() {
const kb = this._keybindingService.lookupKeybinding(this._action.id);
const kb = this._keybindingService.lookupKeybinding(this._action.id, this._contextKeyService);
if (!kb) {
return super.updateLabel();
}
Expand Down Expand Up @@ -49,7 +60,7 @@ export class SuggestWidgetStatus {
this.element = dom.append(container, dom.$('.suggest-status-bar'));

const actionViewItemProvider = <IActionViewItemProvider>(action => {
return action instanceof MenuItemAction ? instantiationService.createInstance(StatusBarViewItem, action, undefined) : undefined;
return action instanceof MenuItemAction ? instantiationService.createInstance(StatusBarViewItem, action) : undefined;
});
this._leftActions = new ActionBar(this.element, { actionViewItemProvider });
this._rightActions = new ActionBar(this.element, { actionViewItemProvider });
Expand Down

0 comments on commit 84323a8

Please sign in to comment.