提交 2524412d 编写于 作者: A Alex Ross

Keep process info when forwarding candidate port

Fixes https://github.com/microsoft/vscode/issues/89424
上级 a99b0779
......@@ -57,7 +57,7 @@ export interface ITunnelViewModel {
onForwardedPortsChanged: Event<void>;
readonly forwarded: TunnelItem[];
readonly detected: TunnelItem[];
readonly candidates: Promise<TunnelItem[]>;
readonly candidates: TunnelItem[];
readonly input: TunnelItem;
groups(): Promise<ITunnelGroup[]>;
}
......@@ -67,6 +67,7 @@ export class TunnelViewModel extends Disposable implements ITunnelViewModel {
public onForwardedPortsChanged: Event<void> = this._onForwardedPortsChanged.event;
private model: TunnelModel;
private _input: TunnelItem;
private _candidates: Map<string, { host: string, port: number, detail: string }> = new Map();
constructor(
@IRemoteExplorerService private readonly remoteExplorerService: IRemoteExplorerService) {
......@@ -87,6 +88,10 @@ export class TunnelViewModel extends Disposable implements ITunnelViewModel {
async groups(): Promise<ITunnelGroup[]> {
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<TunnelItem[]> {
return this.model.candidates.then(values => {
get candidates(): TunnelItem[] {
const candidates: TunnelItem[] = [];
values.forEach(value => {
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;
......
......@@ -31,7 +31,7 @@ export interface ITunnelItem {
localAddress?: string;
name?: string;
closeable?: boolean;
readonly description?: string;
description?: string;
readonly label: string;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册