@@ -6,7 +6,7 @@ import * as nls from 'vs/nls';
6
6
import { Disposable , IDisposable } from 'vs/base/common/lifecycle' ;
7
7
import { IWorkbenchContribution } from 'vs/workbench/common/contributions' ;
8
8
import { Extensions , IViewContainersRegistry , IViewsRegistry , ViewContainer , ViewContainerLocation } from 'vs/workbench/common/views' ;
9
- import { Attributes , AutoTunnelSource , IRemoteExplorerService , makeAddress , mapHasAddressLocalhostOrAllInterfaces , OnPortForward , PORT_AUTO_FORWARD_SETTING , PORT_AUTO_SOURCE_SETTING , PORT_AUTO_SOURCE_SETTING_HYBRID , PORT_AUTO_SOURCE_SETTING_OUTPUT , PORT_AUTO_SOURCE_SETTING_PROCESS , TUNNEL_VIEW_CONTAINER_ID , TUNNEL_VIEW_ID , TunnelSource } from 'vs/workbench/services/remote/common/remoteExplorerService' ;
9
+ import { Attributes , AutoTunnelSource , IRemoteExplorerService , makeAddress , mapHasAddressLocalhostOrAllInterfaces , OnPortForward , PORT_AUTO_FORWARD_SETTING , PORT_AUTO_SOURCE_SETTING , PORT_AUTO_SOURCE_SETTING_HYBRID , PORT_AUTO_SOURCE_SETTING_OUTPUT , PORT_AUTO_SOURCE_SETTING_PROCESS , Tunnel , TUNNEL_VIEW_CONTAINER_ID , TUNNEL_VIEW_ID , TunnelSource } from 'vs/workbench/services/remote/common/remoteExplorerService' ;
10
10
import { forwardedPortsViewEnabled , ForwardPortAction , OpenPortInBrowserAction , TunnelPanel , TunnelPanelDescriptor , TunnelViewModel , OpenPortInPreviewAction , openPreviewEnabledContext } from 'vs/workbench/contrib/remote/browser/tunnelView' ;
11
11
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey' ;
12
12
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService' ;
@@ -621,24 +621,29 @@ class ProcAutomaticPortForwarding extends Disposable {
621
621
622
622
private async handleCandidateUpdate ( removed : Map < string , { host : string ; port : number } > ) {
623
623
const removedPorts : number [ ] = [ ] ;
624
- let autoForwarded : Set < string > ;
624
+ let autoForwarded : Map < string , string | Tunnel > ;
625
625
if ( this . unforwardOnly ) {
626
- autoForwarded = new Set ( ) ;
626
+ autoForwarded = new Map ( ) ;
627
627
for ( const entry of this . remoteExplorerService . tunnelModel . forwarded . entries ( ) ) {
628
628
if ( entry [ 1 ] . source . source === TunnelSource . Auto ) {
629
- autoForwarded . add ( entry [ 0 ] ) ;
629
+ autoForwarded . set ( entry [ 0 ] , entry [ 1 ] ) ;
630
630
}
631
631
}
632
632
} else {
633
- autoForwarded = this . autoForwarded ;
633
+ autoForwarded = new Map ( this . autoForwarded . entries ( ) ) ;
634
634
}
635
635
636
636
for ( const removedPort of removed ) {
637
637
const key = removedPort [ 0 ] ;
638
- const value = removedPort [ 1 ] ;
639
- if ( autoForwarded . has ( key ) ) {
638
+ let value = removedPort [ 1 ] ;
639
+ const forwardedValue = mapHasAddressLocalhostOrAllInterfaces ( autoForwarded , value . host , value . port ) ;
640
+ if ( forwardedValue ) {
641
+ if ( typeof forwardedValue === 'string' ) {
642
+ this . autoForwarded . delete ( key ) ;
643
+ } else {
644
+ value = { host : forwardedValue . remoteHost , port : forwardedValue . remotePort } ;
645
+ }
640
646
await this . remoteExplorerService . close ( value ) ;
641
- autoForwarded . delete ( key ) ;
642
647
removedPorts . push ( value . port ) ;
643
648
} else if ( this . notifiedOnly . has ( key ) ) {
644
649
this . notifiedOnly . delete ( key ) ;
0 commit comments