diff --git a/src/vs/workbench/contrib/remote/browser/tunnelView.ts b/src/vs/workbench/contrib/remote/browser/tunnelView.ts index 7991e44e2c9173161e85b81a82296aca94596705..2d5bd081693cc3fb1722b0073596395795a51062 100644 --- a/src/vs/workbench/contrib/remote/browser/tunnelView.ts +++ b/src/vs/workbench/contrib/remote/browser/tunnelView.ts @@ -57,7 +57,7 @@ export interface ITunnelViewModel { onForwardedPortsChanged: Event; readonly forwarded: TunnelItem[]; readonly detected: TunnelItem[]; - readonly candidates: Promise; + readonly candidates: TunnelItem[]; readonly input: TunnelItem; groups(): Promise; } @@ -67,6 +67,7 @@ export class TunnelViewModel extends Disposable implements ITunnelViewModel { public onForwardedPortsChanged: Event = this._onForwardedPortsChanged.event; private model: TunnelModel; private _input: TunnelItem; + private _candidates: Map = new Map(); constructor( @IRemoteExplorerService private readonly remoteExplorerService: IRemoteExplorerService) { @@ -87,6 +88,10 @@ export class TunnelViewModel extends Disposable implements ITunnelViewModel { async groups(): Promise { const groups: ITunnelGroup[] = []; + this._candidates = new Map(); + (await this.model.candidates).forEach(candidate => { + this._candidates.set(MakeAddress(candidate.host, candidate.port), candidate); + }); if ((this.model.forwarded.size > 0) || this.remoteExplorerService.getEditableData(undefined)) { groups.push({ label: nls.localize('remote.tunnelsView.forwarded', "Forwarded"), @@ -115,9 +120,18 @@ export class TunnelViewModel extends Disposable implements ITunnelViewModel { return groups; } + private addProcessInfoFromCandidate(tunnelItem: ITunnelItem) { + const key = MakeAddress(tunnelItem.remoteHost, tunnelItem.remotePort); + if (this._candidates.has(key)) { + tunnelItem.description = this._candidates.get(key)!.detail; + } + } + get forwarded(): TunnelItem[] { const forwarded = Array.from(this.model.forwarded.values()).map(tunnel => { - return TunnelItem.createFromTunnel(tunnel); + const tunnelItem = TunnelItem.createFromTunnel(tunnel); + this.addProcessInfoFromCandidate(tunnelItem); + return tunnelItem; }).sort((a: TunnelItem, b: TunnelItem) => { if (a.remotePort === b.remotePort) { return a.remoteHost < b.remoteHost ? -1 : 1; @@ -133,21 +147,21 @@ export class TunnelViewModel extends Disposable implements ITunnelViewModel { get detected(): TunnelItem[] { return Array.from(this.model.detected.values()).map(tunnel => { - return TunnelItem.createFromTunnel(tunnel, TunnelType.Detected, false); + const tunnelItem = TunnelItem.createFromTunnel(tunnel, TunnelType.Detected, false); + this.addProcessInfoFromCandidate(tunnelItem); + return tunnelItem; }); } - get candidates(): Promise { - return this.model.candidates.then(values => { - const candidates: TunnelItem[] = []; - values.forEach(value => { - const key = MakeAddress(value.host, value.port); - if (!this.model.forwarded.has(key) && !this.model.detected.has(key)) { - candidates.push(new TunnelItem(TunnelType.Candidate, value.host, value.port, undefined, false, undefined, value.detail)); - } - }); - return candidates; + get candidates(): TunnelItem[] { + const candidates: TunnelItem[] = []; + this._candidates.forEach(value => { + const key = MakeAddress(value.host, value.port); + if (!this.model.forwarded.has(key) && !this.model.detected.has(key)) { + candidates.push(new TunnelItem(TunnelType.Candidate, value.host, value.port, undefined, false, undefined, value.detail)); + } }); + return candidates; } get input(): TunnelItem { @@ -386,6 +400,10 @@ class TunnelItem implements ITunnelItem { } } + set description(description: string | undefined) { + this._description = description; + } + get description(): string | undefined { if (this._description) { return this._description; diff --git a/src/vs/workbench/services/remote/common/remoteExplorerService.ts b/src/vs/workbench/services/remote/common/remoteExplorerService.ts index 4ff49607444f7e377d8c940bd6a35bca939a7a5f..67fc3030120381d282d76d03c1fa1c1340f2bf7c 100644 --- a/src/vs/workbench/services/remote/common/remoteExplorerService.ts +++ b/src/vs/workbench/services/remote/common/remoteExplorerService.ts @@ -31,7 +31,7 @@ export interface ITunnelItem { localAddress?: string; name?: string; closeable?: boolean; - readonly description?: string; + description?: string; readonly label: string; }