@@ -842,15 +842,25 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution {
842842
843843class AutomaticPortForwarding extends Disposable implements IWorkbenchContribution {
844844 constructor (
845- @ITerminalService readonly terminalService : ITerminalService ,
846- @INotificationService readonly notificationService : INotificationService ,
847- @IOpenerService readonly openerService : IOpenerService ,
848- @IViewsService readonly viewsService : IViewsService ,
849- @IRemoteExplorerService readonly remoteExplorerService : IRemoteExplorerService ,
850- @IWorkbenchEnvironmentService environmentService : IWorkbenchEnvironmentService ,
845+ @ITerminalService private readonly terminalService : ITerminalService ,
846+ @INotificationService private readonly notificationService : INotificationService ,
847+ @IOpenerService private readonly openerService : IOpenerService ,
848+ @IViewsService private readonly viewsService : IViewsService ,
849+ @IRemoteExplorerService private readonly remoteExplorerService : IRemoteExplorerService ,
850+ @IWorkbenchEnvironmentService private readonly environmentService : IWorkbenchEnvironmentService ,
851+ @IContextKeyService private readonly contextKeyService : IContextKeyService
851852 ) {
852853 super ( ) ;
853- const urlFinder = this . _register ( new UrlFinder ( terminalService ) ) ;
854+ if ( this . environmentService . configuration . remoteAuthority ) {
855+ this . startUrlFinder ( ) ;
856+ }
857+ }
858+
859+ private startUrlFinder ( ) {
860+ if ( ! forwardedPortsViewEnabled . getValue ( this . contextKeyService ) ) {
861+ return ;
862+ }
863+ const urlFinder = this . _register ( new UrlFinder ( this . terminalService ) ) ;
854864 this . _register ( urlFinder . onDidMatchLocalUrl ( async ( localUrl ) => {
855865 const forwarded = await this . remoteExplorerService . forward ( localUrl ) ;
856866 if ( forwarded ) {
@@ -859,20 +869,20 @@ class AutomaticPortForwarding extends Disposable implements IWorkbenchContributi
859869 address , forwarded . localAddress ) ;
860870 const browserChoice : IPromptChoice = {
861871 label : OpenPortInBrowserAction . LABEL ,
862- run : ( ) => OpenPortInBrowserAction . run ( this . remoteExplorerService . tunnelModel , openerService , address )
872+ run : ( ) => OpenPortInBrowserAction . run ( this . remoteExplorerService . tunnelModel , this . openerService , address )
863873 } ;
864874 const showChoice : IPromptChoice = {
865875 label : nls . localize ( 'remote.tunnelsView.showView' , "Show Forwarded Ports" ) ,
866876 run : ( ) => {
867- const remoteAuthority = environmentService . configuration . remoteAuthority ;
877+ const remoteAuthority = this . environmentService . configuration . remoteAuthority ;
868878 const explorerType : string [ ] | undefined = remoteAuthority ? [ remoteAuthority . split ( '+' ) [ 0 ] ] : undefined ;
869879 if ( explorerType ) {
870- remoteExplorerService . targetType = explorerType ;
880+ this . remoteExplorerService . targetType = explorerType ;
871881 }
872- viewsService . openViewContainer ( VIEWLET_ID ) ;
882+ this . viewsService . openViewContainer ( VIEWLET_ID ) ;
873883 }
874884 } ;
875- notificationService . prompt ( Severity . Info , message , [ browserChoice , showChoice ] , { neverShowAgain : { id : 'remote.tunnelsView.autoForwardNeverShow' , isSecondary : true } } ) ;
885+ this . notificationService . prompt ( Severity . Info , message , [ browserChoice , showChoice ] , { neverShowAgain : { id : 'remote.tunnelsView.autoForwardNeverShow' , isSecondary : true } } ) ;
876886 }
877887 } ) ) ;
878888 }
0 commit comments