diff --git a/src/vs/workbench/api/common/menusExtensionPoint.ts b/src/vs/workbench/api/common/menusExtensionPoint.ts index 078eff7442f..6360dadf550 100644 --- a/src/vs/workbench/api/common/menusExtensionPoint.ts +++ b/src/vs/workbench/api/common/menusExtensionPoint.ts @@ -182,6 +182,11 @@ const apiMenus: IAPIMenu[] = [ id: MenuId.TimelineItemContext, description: localize('view.timelineContext', "The Timeline view item context menu") }, + { + key: 'ports/item/context', + id: MenuId.TunnelContext, + description: localize('view.tunnelContext', "The Ports view item context menu") + } ]; namespace schema { diff --git a/src/vs/workbench/contrib/remote/browser/tunnelView.ts b/src/vs/workbench/contrib/remote/browser/tunnelView.ts index 53b3382d388..f2808ab0899 100644 --- a/src/vs/workbench/contrib/remote/browser/tunnelView.ts +++ b/src/vs/workbench/contrib/remote/browser/tunnelView.ts @@ -812,23 +812,26 @@ namespace LabelTunnelAction { export const LABEL = nls.localize('remote.tunnel.label', "Set Label"); export function handler(): ICommandHandler { - return async (accessor, arg) => { + return async (accessor, arg): Promise<{ port: number, label: string } | undefined> => { const context = (arg !== undefined || arg instanceof TunnelItem) ? arg : accessor.get(IContextKeyService).getContextKeyValue(TunnelViewSelectionKeyName); if (context instanceof TunnelItem) { - const remoteExplorerService = accessor.get(IRemoteExplorerService); - remoteExplorerService.setEditable(context, { - onFinish: async (value, success) => { - if (success) { - remoteExplorerService.tunnelModel.name(context.remoteHost, context.remotePort, value); - } - remoteExplorerService.setEditable(context, null); - }, - validationMessage: () => null, - placeholder: nls.localize('remote.tunnelsView.labelPlaceholder', "Port label"), - startingValue: context.name + return new Promise(resolve => { + const remoteExplorerService = accessor.get(IRemoteExplorerService); + remoteExplorerService.setEditable(context, { + onFinish: async (value, success) => { + if (success) { + remoteExplorerService.tunnelModel.name(context.remoteHost, context.remotePort, value); + } + remoteExplorerService.setEditable(context, null); + resolve(success ? { port: context.remotePort, label: value } : undefined); + }, + validationMessage: () => null, + placeholder: nls.localize('remote.tunnelsView.labelPlaceholder', "Port label"), + startingValue: context.name + }); }); } - return; + return undefined; }; } }