Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small cleanup to ActionWidgetService #172028

Merged
merged 1 commit into from
Jan 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/vs/platform/actionWidget/browser/actionWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { Disposable, DisposableStore, IDisposable, MutableDisposable } from 'vs/base/common/lifecycle';
import 'vs/css!./actionWidget';
import { localize } from 'vs/nls';
import { Action2, registerAction2 } from 'vs/platform/actions/common/actions';
import { acceptSelectedActionCommand, ActionList, IListMenuItem, previewSelectedActionCommand } from 'vs/platform/actionWidget/browser/actionList';
import { IActionItem } from 'vs/platform/actionWidget/common/actionWidget';
import { Action2, registerAction2 } from 'vs/platform/actions/common/actions';
import { IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions';
Expand All @@ -34,7 +34,7 @@ export const IActionWidgetService = createDecorator<IActionWidgetService>('actio
export interface IActionWidgetService {
readonly _serviceBrand: undefined;

show(user: string, supportsPreview: boolean, items: IListMenuItem<IActionItem>[], delegate: IRenderDelegate<any>, anchor: IAnchor, container: HTMLElement | undefined, actionBarActions?: readonly IAction[]): Promise<void>;
show(user: string, supportsPreview: boolean, items: readonly IListMenuItem<IActionItem>[], delegate: IRenderDelegate<any>, anchor: IAnchor, container: HTMLElement | undefined, actionBarActions?: readonly IAction[]): void;

hide(): void;

Expand All @@ -51,26 +51,26 @@ class ActionWidgetService extends Disposable implements IActionWidgetService {
private readonly _list = this._register(new MutableDisposable<ActionList<any>>());

constructor(
@IContextViewService private readonly contextViewService: IContextViewService,
@IContextViewService private readonly _contextViewService: IContextViewService,
@IContextKeyService private readonly _contextKeyService: IContextKeyService,
@IInstantiationService private readonly _instantiationService: IInstantiationService
) {
super();
}

async show(user: string, supportsPreview: boolean, items: IListMenuItem<IActionItem>[], delegate: IRenderDelegate<any>, anchor: IAnchor, container: HTMLElement | undefined, actionBarActions?: readonly IAction[]): Promise<void> {
show(user: string, supportsPreview: boolean, items: readonly IListMenuItem<IActionItem>[], delegate: IRenderDelegate<any>, anchor: IAnchor, container: HTMLElement | undefined, actionBarActions?: readonly IAction[]): void {
const visibleContext = ActionWidgetContextKeys.Visible.bindTo(this._contextKeyService);

const list = this._instantiationService.createInstance(ActionList, user, supportsPreview, items, delegate);
this.contextViewService.showContextView({
this._contextViewService.showContextView({
getAnchor: () => anchor,
render: (container: HTMLElement) => {
visibleContext.set(true);
return this._renderWidget(container, list, actionBarActions ?? []);
},
onHide: (didCancel) => {
visibleContext.reset();
return this._onWidgetClosed(didCancel);
this._onWidgetClosed(didCancel);
},
}, container, false);
}
Expand Down