@@ -354,8 +354,11 @@ export class GitpodWorkspaceTreeDataProvider implements vscode.TreeDataProvider<
354
354
const localPort = portStatus . getLocalPort ( ) ;
355
355
const tunnel = this . tunnelMap . get ( localPort ) ;
356
356
toClean ?. delete ( localPort ) ;
357
- const port = this . ports . ports . get ( localPort ) || new PortTreeItem ( new GitpodWorkspacePort ( localPort , this . context , portStatus , tunnel ) ) ;
358
- const prevStatus = port . port . status ;
357
+ let port = this . ports . ports . get ( localPort ) ;
358
+ const prevStatus = port ?. port . status ;
359
+ if ( ! port ) {
360
+ port = new PortTreeItem ( new GitpodWorkspacePort ( localPort , this . context , portStatus , tunnel ) ) ;
361
+ }
359
362
this . ports . ports . set ( localPort , port ) ;
360
363
361
364
port . port . update ( portStatus , tunnel ) ;
@@ -435,18 +438,18 @@ export class GitpodPortViewProvider implements vscode.WebviewViewProvider {
435
438
// content="default-src 'none'; img-src data: ${webview.cspSource}; font-src ${webview.cspSource}; style-src ${webview.cspSource} 'nonce-${nonce}'; script-src 'nonce-${nonce}';"
436
439
// />
437
440
return `<!DOCTYPE html>
438
- <html lang="en">
439
- <head>
440
- <meta charset="UTF-8" />
441
- <meta http-equiv="X-UA-Compatible" content="IE=edge" />
442
-
443
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
444
- <link nonce="${ nonce } " href="${ styleUri } " rel="stylesheet" />
445
- <title>Gitpod Port View</title>
446
- </head>
447
- <body></body>
448
- <script nonce="${ nonce } " src="${ scriptUri } "></script>
449
- </html>`;
441
+ <html lang="en">
442
+ <head>
443
+ <meta charset="UTF-8" />
444
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
445
+
446
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
447
+ <link nonce="${ nonce } " href="${ styleUri } " rel="stylesheet" />
448
+ <title>Gitpod Port View</title>
449
+ </head>
450
+ <body></body>
451
+ <script nonce="${ nonce } " src="${ scriptUri } "></script>
452
+ </html>`;
450
453
}
451
454
452
455
private tunnelsMap = new Map < number , vscode . TunnelDescription > ( ) ;
@@ -469,14 +472,15 @@ export class GitpodPortViewProvider implements vscode.WebviewViewProvider {
469
472
if ( ! this . portStatus ) { return ; }
470
473
this . portStatus . getPortsList ( ) . forEach ( e => {
471
474
const localPort = e . getLocalPort ( ) ;
472
- const gitpodPort = this . portMap . get ( localPort ) ;
473
475
const tunnel = this . tunnelsMap . get ( localPort ) ;
476
+ let gitpodPort = this . portMap . get ( localPort ) ;
477
+ const prevStatus = gitpodPort ?. status ;
474
478
if ( ! gitpodPort ) {
475
- this . portMap . set ( localPort , new GitpodWorkspacePort ( localPort , this . context , e , tunnel ) ) ;
476
- return ;
479
+ gitpodPort = new GitpodWorkspacePort ( localPort , this . context , e , tunnel ) ;
480
+ this . portMap . set ( localPort , gitpodPort ) ;
481
+ } else {
482
+ gitpodPort . update ( e , tunnel ) ;
477
483
}
478
- const prevStatus = gitpodPort . status ;
479
- gitpodPort . update ( e , tunnel ) ;
480
484
if ( isExposedServedGitpodWorkspacePort ( gitpodPort ) && ! isExposedServedPort ( prevStatus ) ) {
481
485
this . onDidExposeServedPortEmitter . fire ( gitpodPort ) ;
482
486
}
0 commit comments