diff --git a/src/vs/platform/actions/common/actions.ts b/src/vs/platform/actions/common/actions.ts index 7c036d9278c7ec4aba65e1567e16fc027a45dc02..c4fc2dd98266163db25a619d160cf9fab4afeafb 100644 --- a/src/vs/platform/actions/common/actions.ts +++ b/src/vs/platform/actions/common/actions.ts @@ -348,20 +348,20 @@ export class SyncActionDescriptor { type OneOrN = T | T[]; -export interface IAction2Description extends ICommandAction { +export interface IAction2Options extends ICommandAction { f1?: boolean; menu?: OneOrN<{ id: MenuId } & Omit>; keybinding?: Omit; } -export interface IAction2 { - readonly desc: IAction2Description; - run(accessor: ServicesAccessor, ...args: any): any; +export abstract class Action2 { + constructor(readonly desc: Readonly) { } + abstract run(accessor: ServicesAccessor, ...args: any[]): any; } -export function registerAction2(action: IAction2): IDisposable { +export function registerAction2(ctor: { new(): Action2 }): IDisposable { const disposables = new DisposableStore(); - + const action = new ctor(); disposables.add(CommandsRegistry.registerCommand({ id: action.desc.id, handler: (accessor, ...args) => action.run(accessor, ...args), diff --git a/src/vs/workbench/contrib/bulkEdit/browser/bulkEdit.contribution.ts b/src/vs/workbench/contrib/bulkEdit/browser/bulkEdit.contribution.ts index 8e1ec18afc505e862a76efdc6db9d6398abb8482..ec287b316d4be791f7f975e453ff0a8cf1b9c8b0 100644 --- a/src/vs/workbench/contrib/bulkEdit/browser/bulkEdit.contribution.ts +++ b/src/vs/workbench/contrib/bulkEdit/browser/bulkEdit.contribution.ts @@ -23,7 +23,7 @@ import { KeyMod, KeyCode } from 'vs/base/common/keyCodes'; import { WorkbenchListFocusContextKey } from 'vs/platform/list/browser/listService'; import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { URI } from 'vs/base/common/uri'; -import { MenuId, registerAction2, IAction2 } from 'vs/platform/actions/common/actions'; +import { MenuId, registerAction2, Action2 } from 'vs/platform/actions/common/actions'; import { IEditorInput } from 'vs/workbench/common/editor'; import type { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; @@ -112,28 +112,30 @@ class BulkEditPreviewContribution { // CMD: accept -registerAction2(new class ApplyAction implements IAction2 { - - readonly desc = { - id: 'refactorPreview.apply', - title: { value: localize('apply', "Apply Refactoring"), original: 'Apply Refactoring' }, - category: localize('cat', "Refactor Preview"), - icon: { id: 'codicon/check' }, - precondition: BulkEditPreviewContribution.ctxEnabled, - menu: [{ - id: MenuId.ViewTitle, - when: ContextKeyExpr.equals('view', BulkEditPane.ID), - group: 'navigation' - }, { - id: MenuId.BulkEditPaneContext, - order: 1 - }], - keybinding: { - weight: KeybindingWeight.WorkbenchContrib, - when: BulkEditPreviewContribution.ctxEnabled, - primary: KeyMod.Shift + KeyCode.Enter, - } - }; +registerAction2(class ApplyAction extends Action2 { + + constructor() { + super({ + id: 'refactorPreview.apply', + title: { value: localize('apply', "Apply Refactoring"), original: 'Apply Refactoring' }, + category: localize('cat', "Refactor Preview"), + icon: { id: 'codicon/check' }, + precondition: BulkEditPreviewContribution.ctxEnabled, + menu: [{ + id: MenuId.ViewTitle, + when: ContextKeyExpr.equals('view', BulkEditPane.ID), + group: 'navigation' + }, { + id: MenuId.BulkEditPaneContext, + order: 1 + }], + keybinding: { + weight: KeybindingWeight.WorkbenchContrib, + when: BulkEditPreviewContribution.ctxEnabled, + primary: KeyMod.Shift + KeyCode.Enter, + } + }); + } run(accessor: ServicesAccessor): any { const panelService = accessor.get(IPanelService); @@ -145,23 +147,25 @@ registerAction2(new class ApplyAction implements IAction2 { }); // CMD: discard -registerAction2(new class DiscardAction implements IAction2 { - - readonly desc = { - id: 'refactorPreview.discard', - title: { value: localize('Discard', "Discard Refactoring"), original: 'Discard Refactoring' }, - category: localize('cat', "Refactor Preview"), - icon: { id: 'codicon/clear-all' }, - precondition: BulkEditPreviewContribution.ctxEnabled, - menu: [{ - id: MenuId.ViewTitle, - when: ContextKeyExpr.equals('view', BulkEditPane.ID), - group: 'navigation' - }, { - id: MenuId.BulkEditPaneContext, - order: 2 - }] - }; +registerAction2(class DiscardAction extends Action2 { + + constructor() { + super({ + id: 'refactorPreview.discard', + title: { value: localize('Discard', "Discard Refactoring"), original: 'Discard Refactoring' }, + category: localize('cat', "Refactor Preview"), + icon: { id: 'codicon/clear-all' }, + precondition: BulkEditPreviewContribution.ctxEnabled, + menu: [{ + id: MenuId.ViewTitle, + when: ContextKeyExpr.equals('view', BulkEditPane.ID), + group: 'navigation' + }, { + id: MenuId.BulkEditPaneContext, + order: 2 + }] + }); + } run(accessor: ServicesAccessor): void | Promise { const panelService = accessor.get(IPanelService); @@ -174,24 +178,26 @@ registerAction2(new class DiscardAction implements IAction2 { // CMD: toggle -registerAction2(new class ToggleAction implements IAction2 { - - readonly desc = { - id: 'refactorPreview.toggleCheckedState', - title: { value: localize('toogleSelection', "Accept Change"), original: 'Accept Change' }, - category: localize('cat', "Refactor Preview"), - precondition: BulkEditPreviewContribution.ctxEnabled, - toggled: BulkEditPane.ctxChangeChecked, - keybinding: { - weight: KeybindingWeight.WorkbenchContrib, - when: WorkbenchListFocusContextKey, - primary: KeyCode.Space, - }, - menu: { - id: MenuId.BulkEditPaneContext, - group: 'navigation' - } - }; +registerAction2(class ToggleAction extends Action2 { + + constructor() { + super({ + id: 'refactorPreview.toggleCheckedState', + title: { value: localize('toogleSelection', "Accept Change"), original: 'Accept Change' }, + category: localize('cat', "Refactor Preview"), + precondition: BulkEditPreviewContribution.ctxEnabled, + toggled: BulkEditPane.ctxChangeChecked, + keybinding: { + weight: KeybindingWeight.WorkbenchContrib, + when: WorkbenchListFocusContextKey, + primary: KeyCode.Space, + }, + menu: { + id: MenuId.BulkEditPaneContext, + group: 'navigation' + } + }); + } run(accessor: ServicesAccessor): void | Promise { const panelService = accessor.get(IPanelService); diff --git a/src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts b/src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts index 54100b78d50bbd86a1be42ce0eab423ae58170e6..f5fe47a7c0982dde8c73036882f98072136aa132 100644 --- a/src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts +++ b/src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts @@ -6,7 +6,7 @@ import { localize } from 'vs/nls'; import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes'; import { Registry } from 'vs/platform/registry/common/platform'; -import { SyncActionDescriptor, MenuRegistry, MenuId, registerAction2 } from 'vs/platform/actions/common/actions'; +import { SyncActionDescriptor, MenuRegistry, MenuId, registerAction2, Action2 } from 'vs/platform/actions/common/actions'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { ExtensionsLabel, ExtensionsChannelId, PreferencesLabel, IExtensionManagementService, IExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionManagement'; import { IExtensionManagementServerService, IExtensionTipsService } from 'vs/workbench/services/extensionManagement/common/extensionManagement'; @@ -341,16 +341,20 @@ MenuRegistry.appendMenuItem(MenuId.GlobalActivity, { // Extension Context Menu -registerAction2({ - desc: { - id: 'workbench.extensions.action.copyExtension', - title: { value: localize('workbench.extensions.action.copyExtension', "Copy"), original: 'Copy' }, - menu: { - id: MenuId.ExtensionContext, - group: '1_copy' - } - }, - async run(accessor, extensionId: string) { +registerAction2(class extends Action2 { + + constructor() { + super({ + id: 'workbench.extensions.action.copyExtension', + title: { value: localize('workbench.extensions.action.copyExtension', "Copy"), original: 'Copy' }, + menu: { + id: MenuId.ExtensionContext, + group: '1_copy' + } + }); + } + + async run(accessor: ServicesAccessor, extensionId: string) { const extensionWorkbenchService = accessor.get(IExtensionsWorkbenchService); let extension = extensionWorkbenchService.local.filter(e => areSameExtensions(e.identifier, { id: extensionId }))[0] || (await extensionWorkbenchService.queryGallery({ names: [extensionId], pageSize: 1 }, CancellationToken.None)).firstPage[0]; @@ -367,33 +371,41 @@ registerAction2({ } }); -registerAction2({ - desc: { - id: 'workbench.extensions.action.copyExtensionId', - title: { value: localize('workbench.extensions.action.copyExtensionId', "Copy Extension Id"), original: 'Copy Extension Id' }, - menu: { - id: MenuId.ExtensionContext, - group: '1_copy' - } - }, - async run(accessor, id: string) { +registerAction2(class extends Action2 { + + constructor() { + super({ + id: 'workbench.extensions.action.copyExtensionId', + title: { value: localize('workbench.extensions.action.copyExtensionId', "Copy Extension Id"), original: 'Copy Extension Id' }, + menu: { + id: MenuId.ExtensionContext, + group: '1_copy' + } + }); + } + + async run(accessor: ServicesAccessor, id: string) { await accessor.get(IClipboardService).writeText(id); - }, + } }); -registerAction2({ - desc: { - id: 'workbench.extensions.action.configure', - title: { value: localize('workbench.extensions.action.configure', "Configure..."), original: 'Configure...' }, - menu: { - id: MenuId.ExtensionContext, - group: '2_configure', - when: ContextKeyExpr.and(ContextKeyExpr.equals('extensionStatus', 'installed'), ContextKeyExpr.has('extensionHasConfiguration')) - } - }, - async run(accessor, id: string) { +registerAction2(class extends Action2 { + + constructor() { + super({ + id: 'workbench.extensions.action.configure', + title: { value: localize('workbench.extensions.action.configure', "Configure..."), original: 'Configure...' }, + menu: { + id: MenuId.ExtensionContext, + group: '2_configure', + when: ContextKeyExpr.and(ContextKeyExpr.equals('extensionStatus', 'installed'), ContextKeyExpr.has('extensionHasConfiguration')) + } + }); + } + + async run(accessor: ServicesAccessor, id: string) { await accessor.get(IPreferencesService).openSettings(false, `@ext:${id}`); - }, + } }); const workbenchRegistry = Registry.as(WorkbenchExtensions.Workbench); diff --git a/src/vs/workbench/contrib/markers/browser/markers.contribution.ts b/src/vs/workbench/contrib/markers/browser/markers.contribution.ts index 415fa4238caab4564373e80ccc8dcfe04bca9cbe..47bf7f1fff1d9f4ecdb5301244568d0747babc5a 100644 --- a/src/vs/workbench/contrib/markers/browser/markers.contribution.ts +++ b/src/vs/workbench/contrib/markers/browser/markers.contribution.ts @@ -13,7 +13,7 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import { localize } from 'vs/nls'; import { Marker, RelatedInformation } from 'vs/workbench/contrib/markers/browser/markersModel'; import { MarkersView, getMarkersView } from 'vs/workbench/contrib/markers/browser/markersView'; -import { MenuId, MenuRegistry, SyncActionDescriptor, registerAction2 } from 'vs/platform/actions/common/actions'; +import { MenuId, MenuRegistry, SyncActionDescriptor, registerAction2, Action2 } from 'vs/platform/actions/common/actions'; import { TogglePanelAction } from 'vs/workbench/browser/panel'; import { Registry } from 'vs/platform/registry/common/platform'; import { ShowProblemsPanelAction } from 'vs/workbench/contrib/markers/browser/markersViewActions'; @@ -33,6 +33,7 @@ import { ViewContainer, IViewContainersRegistry, Extensions as ViewContainerExte import { ViewPaneContainer } from 'vs/workbench/browser/parts/views/viewPaneContainer'; import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; +import type { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; registerSingleton(IMarkersWorkbenchService, MarkersWorkbenchService, false); @@ -136,109 +137,123 @@ registry.registerWorkbenchAction(SyncActionDescriptor.create(ToggleMarkersPanelA primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_M }), 'View: Toggle Problems (Errors, Warnings, Infos)', Messages.MARKERS_PANEL_VIEW_CATEGORY); registry.registerWorkbenchAction(SyncActionDescriptor.create(ShowProblemsPanelAction, ShowProblemsPanelAction.ID, ShowProblemsPanelAction.LABEL), 'View: Focus Problems (Errors, Warnings, Infos)', Messages.MARKERS_PANEL_VIEW_CATEGORY); -registerAction2({ - desc: { - id: Constants.MARKER_COPY_ACTION_ID, - title: { value: localize('copyMarker', "Copy"), original: 'Copy' }, - menu: { - id: MenuId.ProblemsPanelContext, - when: Constants.MarkerFocusContextKey, - group: 'navigation' - }, - keybinding: { - weight: KeybindingWeight.WorkbenchContrib, - primary: KeyMod.CtrlCmd | KeyCode.KEY_C, - when: Constants.MarkerFocusContextKey - }, - }, - async run(accessor) { +registerAction2(class extends Action2 { + constructor() { + super({ + id: Constants.MARKER_COPY_ACTION_ID, + title: { value: localize('copyMarker', "Copy"), original: 'Copy' }, + menu: { + id: MenuId.ProblemsPanelContext, + when: Constants.MarkerFocusContextKey, + group: 'navigation' + }, + keybinding: { + weight: KeybindingWeight.WorkbenchContrib, + primary: KeyMod.CtrlCmd | KeyCode.KEY_C, + when: Constants.MarkerFocusContextKey + }, + }); + } + async run(accessor: ServicesAccessor) { await copyMarker(accessor.get(IPanelService), accessor.get(IClipboardService)); - }, + } }); -registerAction2({ - desc: { - id: Constants.MARKER_COPY_MESSAGE_ACTION_ID, - title: { value: localize('copyMessage', "Copy Message"), original: 'Copy Message' }, - menu: { - id: MenuId.ProblemsPanelContext, - when: Constants.MarkerFocusContextKey, - group: 'navigation' - }, - }, - async run(accessor) { +registerAction2(class extends Action2 { + constructor() { + super({ + id: Constants.MARKER_COPY_MESSAGE_ACTION_ID, + title: { value: localize('copyMessage', "Copy Message"), original: 'Copy Message' }, + menu: { + id: MenuId.ProblemsPanelContext, + when: Constants.MarkerFocusContextKey, + group: 'navigation' + }, + }); + } + async run(accessor: ServicesAccessor) { await copyMessage(accessor.get(IPanelService), accessor.get(IClipboardService)); - }, + } }); -registerAction2({ - desc: { - id: Constants.RELATED_INFORMATION_COPY_MESSAGE_ACTION_ID, - title: { value: localize('copyMessage', "Copy Message"), original: 'Copy Message' }, - menu: { - id: MenuId.ProblemsPanelContext, - when: Constants.RelatedInformationFocusContextKey, - group: 'navigation' - } - }, - async run(accessor) { +registerAction2(class extends Action2 { + constructor() { + super({ + id: Constants.RELATED_INFORMATION_COPY_MESSAGE_ACTION_ID, + title: { value: localize('copyMessage', "Copy Message"), original: 'Copy Message' }, + menu: { + id: MenuId.ProblemsPanelContext, + when: Constants.RelatedInformationFocusContextKey, + group: 'navigation' + } + }); + } + async run(accessor: ServicesAccessor) { await copyRelatedInformationMessage(accessor.get(IPanelService), accessor.get(IClipboardService)); } }); -registerAction2({ - desc: { - id: Constants.FOCUS_PROBLEMS_FROM_FILTER, - title: localize('focusProblemsList', "Focus problems view"), - keybinding: { - when: Constants.MarkerPanelFilterFocusContextKey, - weight: KeybindingWeight.WorkbenchContrib, - primary: KeyMod.CtrlCmd | KeyCode.DownArrow - } - }, - run(accessor) { +registerAction2(class extends Action2 { + constructor() { + super({ + id: Constants.FOCUS_PROBLEMS_FROM_FILTER, + title: localize('focusProblemsList', "Focus problems view"), + keybinding: { + when: Constants.MarkerPanelFilterFocusContextKey, + weight: KeybindingWeight.WorkbenchContrib, + primary: KeyMod.CtrlCmd | KeyCode.DownArrow + } + }); + } + run(accessor: ServicesAccessor) { focusProblemsView(accessor.get(IPanelService)); } }); -registerAction2({ - desc: { - id: Constants.MARKERS_PANEL_FOCUS_FILTER, - title: localize('focusProblemsFilter', "Focus problems filter"), - keybinding: { - when: Constants.MarkerPanelFocusContextKey, - weight: KeybindingWeight.WorkbenchContrib, - primary: KeyMod.CtrlCmd | KeyCode.KEY_F - } - }, - run(accessor) { +registerAction2(class extends Action2 { + constructor() { + super({ + id: Constants.MARKERS_PANEL_FOCUS_FILTER, + title: localize('focusProblemsFilter', "Focus problems filter"), + keybinding: { + when: Constants.MarkerPanelFocusContextKey, + weight: KeybindingWeight.WorkbenchContrib, + primary: KeyMod.CtrlCmd | KeyCode.KEY_F + } + }); + } + run(accessor: ServicesAccessor) { focusProblemsFilter(accessor.get(IPanelService)); } }); -registerAction2({ - desc: { - id: Constants.MARKERS_PANEL_SHOW_MULTILINE_MESSAGE, - title: { value: localize('show multiline', "Show message in multiple lines"), original: 'Problems: Show message in multiple lines' }, - category: localize('problems', "Problems"), - menu: { - id: MenuId.CommandPalette, - when: ActivePanelContext.isEqualTo(Constants.MARKERS_PANEL_ID) - } - }, - run(accessor) { +registerAction2(class extends Action2 { + constructor() { + super({ + id: Constants.MARKERS_PANEL_SHOW_MULTILINE_MESSAGE, + title: { value: localize('show multiline', "Show message in multiple lines"), original: 'Problems: Show message in multiple lines' }, + category: localize('problems', "Problems"), + menu: { + id: MenuId.CommandPalette, + when: ActivePanelContext.isEqualTo(Constants.MARKERS_PANEL_ID) + } + }); + } + run(accessor: ServicesAccessor) { const markersView = getMarkersView(accessor.get(IPanelService)); if (markersView) { markersView.markersViewModel.multiline = true; } } }); -registerAction2({ - desc: { - id: Constants.MARKERS_PANEL_SHOW_SINGLELINE_MESSAGE, - title: { value: localize('show singleline', "Show message in single line"), original: 'Problems: Show message in single line' }, - category: localize('problems', "Problems"), - menu: { - id: MenuId.CommandPalette, - when: ActivePanelContext.isEqualTo(Constants.MARKERS_PANEL_ID) - } - }, - run(accessor) { +registerAction2(class extends Action2 { + constructor() { + super({ + id: Constants.MARKERS_PANEL_SHOW_SINGLELINE_MESSAGE, + title: { value: localize('show singleline', "Show message in single line"), original: 'Problems: Show message in single line' }, + category: localize('problems', "Problems"), + menu: { + id: MenuId.CommandPalette, + when: ActivePanelContext.isEqualTo(Constants.MARKERS_PANEL_ID) + } + }); + } + run(accessor: ServicesAccessor) { const markersView = getMarkersView(accessor.get(IPanelService)); if (markersView) { markersView.markersViewModel.multiline = false; diff --git a/src/vs/workbench/contrib/output/browser/output.contribution.ts b/src/vs/workbench/contrib/output/browser/output.contribution.ts index 13a9fd16f1f73151aead91eaf0b3d44a899621aa..5bff7445b919c399420160bc984a24f59c2f0880 100644 --- a/src/vs/workbench/contrib/output/browser/output.contribution.ts +++ b/src/vs/workbench/contrib/output/browser/output.contribution.ts @@ -7,7 +7,7 @@ import * as nls from 'vs/nls'; import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes'; import { ModesRegistry } from 'vs/editor/common/modes/modesRegistry'; import { Registry } from 'vs/platform/registry/common/platform'; -import { MenuId, MenuRegistry, SyncActionDescriptor, registerAction2 } from 'vs/platform/actions/common/actions'; +import { MenuId, MenuRegistry, SyncActionDescriptor, registerAction2, Action2 } from 'vs/platform/actions/common/actions'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions'; import { OutputService, LogContentProvider } from 'vs/workbench/contrib/output/browser/outputServices'; @@ -20,7 +20,7 @@ import { LogViewer, LogViewerInput } from 'vs/workbench/contrib/output/browser/l import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions, IWorkbenchContribution } from 'vs/workbench/common/contributions'; import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle'; -import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; +import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; import { ITextModelService } from 'vs/editor/common/services/resolverService'; // Register Service @@ -89,16 +89,18 @@ actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(ShowLogsOutpu actionRegistry.registerWorkbenchAction(SyncActionDescriptor.create(OpenOutputLogFileAction, OpenOutputLogFileAction.ID, OpenOutputLogFileAction.LABEL), 'Developer: Open Log File...', devCategory); // Define clear command, contribute to editor context menu -registerAction2({ - desc: { - id: 'editor.action.clearoutput', - title: { value: nls.localize('clearOutput.label', "Clear Output"), original: 'Clear Output' }, - menu: { - id: MenuId.EditorContext, - when: CONTEXT_IN_OUTPUT - }, - }, - run(accessor) { +registerAction2(class extends Action2 { + constructor() { + super({ + id: 'editor.action.clearoutput', + title: { value: nls.localize('clearOutput.label', "Clear Output"), original: 'Clear Output' }, + menu: { + id: MenuId.EditorContext, + when: CONTEXT_IN_OUTPUT + }, + }); + } + run(accessor: ServicesAccessor) { const activeChannel = accessor.get(IOutputService).getActiveChannel(); if (activeChannel) { activeChannel.clear(); @@ -106,16 +108,18 @@ registerAction2({ } }); -registerAction2({ - desc: { - id: 'workbench.action.openActiveLogOutputFile', - title: { value: nls.localize('openActiveLogOutputFile', "Open Active Log Output File"), original: 'Open Active Log Output File' }, - menu: { - id: MenuId.CommandPalette, - when: CONTEXT_ACTIVE_LOG_OUTPUT - }, - }, - run(accessor) { +registerAction2(class extends Action2 { + constructor() { + super({ + id: 'workbench.action.openActiveLogOutputFile', + title: { value: nls.localize('openActiveLogOutputFile', "Open Active Log Output File"), original: 'Open Active Log Output File' }, + menu: { + id: MenuId.CommandPalette, + when: CONTEXT_ACTIVE_LOG_OUTPUT + }, + }); + } + run(accessor: ServicesAccessor) { accessor.get(IInstantiationService).createInstance(OpenLogOutputFile).run(); } }); diff --git a/src/vs/workbench/contrib/remote/electron-browser/remote.contribution.ts b/src/vs/workbench/contrib/remote/electron-browser/remote.contribution.ts index 965821ee7bdb75afe7cbe3aa5d77cc8babec435b..69209fe8950379740f6e52fdf91c90e476d5fee3 100644 --- a/src/vs/workbench/contrib/remote/electron-browser/remote.contribution.ts +++ b/src/vs/workbench/contrib/remote/electron-browser/remote.contribution.ts @@ -12,7 +12,7 @@ import { Disposable } from 'vs/base/common/lifecycle'; import { isMacintosh } from 'vs/base/common/platform'; import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes'; import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; -import { MenuId, IMenuService, MenuItemAction, IMenu, MenuRegistry, registerAction2 } from 'vs/platform/actions/common/actions'; +import { MenuId, IMenuService, MenuItemAction, IMenu, MenuRegistry, registerAction2, Action2 } from 'vs/platform/actions/common/actions'; import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions as WorkbenchContributionsExtensions } from 'vs/workbench/common/contributions'; import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle'; import { StatusbarAlignment, IStatusbarService, IStatusbarEntryAccessor, IStatusbarEntry } from 'vs/workbench/services/statusbar/common/statusbar'; @@ -70,29 +70,33 @@ export class RemoteWindowActiveIndicator extends Disposable implements IWorkbenc this._register(this.windowCommandMenu); const category = nls.localize('remote.category', "Remote"); - - registerAction2({ - desc: { - id: WINDOW_ACTIONS_COMMAND_ID, - category, - title: { value: nls.localize('remote.showMenu', "Show Remote Menu"), original: 'Show Remote Menu' }, - f1: true, - }, - run: () => this.showIndicatorActions(this.windowCommandMenu) + const that = this; + registerAction2(class extends Action2 { + constructor() { + super({ + id: WINDOW_ACTIONS_COMMAND_ID, + category, + title: { value: nls.localize('remote.showMenu', "Show Remote Menu"), original: 'Show Remote Menu' }, + f1: true, + }); + } + run = () => that.showIndicatorActions(that.windowCommandMenu); }); this.remoteAuthority = environmentService.configuration.remoteAuthority; Deprecated_RemoteAuthorityContext.bindTo(this.contextKeyService).set(this.remoteAuthority || ''); if (this.remoteAuthority) { - registerAction2({ - desc: { - id: CLOSE_REMOTE_COMMAND_ID, - category, - title: { value: nls.localize('remote.close', "Close Remote Connection"), original: 'Close Remote Connection' }, - f1: true - }, - run: () => this.remoteAuthority && hostService.openWindow({ forceReuseWindow: true }) + registerAction2(class extends Action2 { + constructor() { + super({ + id: CLOSE_REMOTE_COMMAND_ID, + category, + title: { value: nls.localize('remote.close', "Close Remote Connection"), original: 'Close Remote Connection' }, + f1: true + }); + } + run = () => that.remoteAuthority && hostService.openWindow({ forceReuseWindow: true }); }); // Pending entry until extensions are ready