Skip to content

Commit

Permalink
Fix gitpod.yml onOpen not works
Browse files Browse the repository at this point in the history
  • Loading branch information
mustard-mh committed Jul 11, 2022
1 parent 6af72b1 commit 53260ce
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions extensions/gitpod-web/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,11 @@ export class GitpodWorkspaceTreeDataProvider implements vscode.TreeDataProvider<
const localPort = portStatus.getLocalPort();
const tunnel = this.tunnelMap.get(localPort);
toClean?.delete(localPort);
const port = this.ports.ports.get(localPort) || new PortTreeItem(new GitpodWorkspacePort(localPort, this.context, portStatus, tunnel));
const prevStatus = port.port.status;
let port = this.ports.ports.get(localPort);
const prevStatus = port?.port.status;
if (!port) {
port = new PortTreeItem(new GitpodWorkspacePort(localPort, this.context, portStatus, tunnel));
}
this.ports.ports.set(localPort, port);

port.port.update(portStatus, tunnel);
Expand Down Expand Up @@ -435,18 +438,18 @@ export class GitpodPortViewProvider implements vscode.WebviewViewProvider {
// content="default-src 'none'; img-src data: ${webview.cspSource}; font-src ${webview.cspSource}; style-src ${webview.cspSource} 'nonce-${nonce}'; script-src 'nonce-${nonce}';"
// />
return `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link nonce="${nonce}" href="${styleUri}" rel="stylesheet" />
<title>Gitpod Port View</title>
</head>
<body></body>
<script nonce="${nonce}" src="${scriptUri}"></script>
</html>`;
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link nonce="${nonce}" href="${styleUri}" rel="stylesheet" />
<title>Gitpod Port View</title>
</head>
<body></body>
<script nonce="${nonce}" src="${scriptUri}"></script>
</html>`;
}

private tunnelsMap = new Map<number, vscode.TunnelDescription>();
Expand All @@ -469,14 +472,15 @@ export class GitpodPortViewProvider implements vscode.WebviewViewProvider {
if (!this.portStatus) { return; }
this.portStatus.getPortsList().forEach(e => {
const localPort = e.getLocalPort();
const gitpodPort = this.portMap.get(localPort);
const tunnel = this.tunnelsMap.get(localPort);
let gitpodPort = this.portMap.get(localPort);
const prevStatus = gitpodPort?.status;
if (!gitpodPort) {
this.portMap.set(localPort, new GitpodWorkspacePort(localPort, this.context, e, tunnel));
return;
gitpodPort = new GitpodWorkspacePort(localPort, this.context, e, tunnel);
this.portMap.set(localPort, gitpodPort);
} else {
gitpodPort.update(e, tunnel);
}
const prevStatus = gitpodPort.status;
gitpodPort.update(e, tunnel);
if (isExposedServedGitpodWorkspacePort(gitpodPort) && !isExposedServedPort(prevStatus)) {
this.onDidExposeServedPortEmitter.fire(gitpodPort);
}
Expand Down

0 comments on commit 53260ce

Please sign in to comment.