@@ -159,7 +159,7 @@ export class TunnelViewModel extends Disposable implements ITunnelViewModel {
159159 this . _candidates . forEach ( value => {
160160 const key = MakeAddress ( value . host , value . port ) ;
161161 if ( ! this . model . forwarded . has ( key ) && ! this . model . detected . has ( key ) ) {
162- candidates . push ( new TunnelItem ( TunnelType . Candidate , value . host , value . port , undefined , false , undefined , value . detail ) ) ;
162+ candidates . push ( new TunnelItem ( TunnelType . Candidate , value . host , value . port , undefined , undefined , false , undefined , value . detail ) ) ;
163163 }
164164 } ) ;
165165 return candidates ;
@@ -375,14 +375,15 @@ interface ITunnelGroup {
375375
376376class TunnelItem implements ITunnelItem {
377377 static createFromTunnel ( tunnel : Tunnel , type : TunnelType = TunnelType . Forwarded , closeable ?: boolean ) {
378- return new TunnelItem ( type , tunnel . remoteHost , tunnel . remotePort , tunnel . localAddress , closeable === undefined ? tunnel . closeable : closeable , tunnel . name , tunnel . description ) ;
378+ return new TunnelItem ( type , tunnel . remoteHost , tunnel . remotePort , tunnel . localAddress , tunnel . localPort , closeable === undefined ? tunnel . closeable : closeable , tunnel . name , tunnel . description ) ;
379379 }
380380
381381 constructor (
382382 public tunnelType : TunnelType ,
383383 public remoteHost : string ,
384384 public remotePort : number ,
385385 public localAddress ?: string ,
386+ public localPort ?: number ,
386387 public closeable ?: boolean ,
387388 public name ?: string ,
388389 private _description ?: string ,
@@ -415,11 +416,6 @@ class TunnelItem implements ITunnelItem {
415416 }
416417}
417418
418- function isHostAndPort ( address : string | undefined ) : boolean {
419- const result = address ? address . match ( / ^ ( l o c a l h o s t | ( [ 0 - 9 ] + \. [ 0 - 9 ] + \. [ 0 - 9 ] + \. [ 0 - 9 ] + ) | ( [ 0 - 9 ] + : [ 0 - 9 ] + : [ 0 - 9 ] + : [ 0 - 9 ] + : [ 0 - 9 ] + : [ 0 - 9 ] + : [ 0 - 9 ] + : [ 0 - 9 ] + ) ) : [ 0 - 9 ] + $ / ) : [ ] ;
420- return ( ! ! result && result . length > 0 ) ;
421- }
422-
423419export const TunnelTypeContextKey = new RawContextKey < TunnelType > ( 'tunnelType' , TunnelType . Add ) ;
424420export const TunnelCloseableContextKey = new RawContextKey < boolean > ( 'tunnelCloseable' , false ) ;
425421const TunnelViewFocusContextKey = new RawContextKey < boolean > ( 'tunnelViewFocus' , false ) ;
@@ -577,7 +573,7 @@ export class TunnelPanel extends ViewPane {
577573 this . tunnelViewSelectionContext . set ( item ) ;
578574 this . tunnelTypeContext . set ( item . tunnelType ) ;
579575 this . tunnelCloseableContext . set ( ! ! item . closeable ) ;
580- this . portChangableContextKey . set ( isHostAndPort ( item . localAddress ) ) ;
576+ this . portChangableContextKey . set ( ! ! item . localPort ) ;
581577 } else {
582578 this . tunnelTypeContext . reset ( ) ;
583579 this . tunnelViewSelectionContext . reset ( ) ;
@@ -600,7 +596,7 @@ export class TunnelPanel extends ViewPane {
600596 this . tree ! . setFocus ( [ node ] ) ;
601597 this . tunnelTypeContext . set ( node . tunnelType ) ;
602598 this . tunnelCloseableContext . set ( ! ! node . closeable ) ;
603- this . portChangableContextKey . set ( isHostAndPort ( node . localAddress ) ) ;
599+ this . portChangableContextKey . set ( ! ! node . localPort ) ;
604600 } else {
605601 this . tunnelTypeContext . set ( TunnelType . Add ) ;
606602 this . tunnelCloseableContext . set ( false ) ;
@@ -1039,7 +1035,7 @@ MenuRegistry.appendMenuItem(MenuId.TunnelContext, ({
10391035 id : ChangeLocalPortAction . ID ,
10401036 title : ChangeLocalPortAction . LABEL ,
10411037 } ,
1042- when : TunnelTypeContextKey . isEqualTo ( TunnelType . Forwarded )
1038+ when : ContextKeyExpr . and ( TunnelTypeContextKey . isEqualTo ( TunnelType . Forwarded ) , PortChangableContextKey )
10431039} ) ) ;
10441040MenuRegistry . appendMenuItem ( MenuId . TunnelContext , ( {
10451041 group : '0_manage' ,
0 commit comments