Skip to content

Commit

Permalink
Fix bad dispose in automatic port forwarding (#108195)
Browse files Browse the repository at this point in the history
Fixes #107243
  • Loading branch information
alexr00 authored Oct 6, 2020
1 parent 2ccf795 commit b0231fd
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/vs/workbench/contrib/remote/browser/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution {
}

class AutomaticPortForwarding extends Disposable implements IWorkbenchContribution {
private contextServiceListener: IDisposable;
private contextServiceListener?: IDisposable;

constructor(
@ITerminalService private readonly terminalService: ITerminalService,
Expand All @@ -855,20 +855,23 @@ class AutomaticPortForwarding extends Disposable implements IWorkbenchContributi
super();
if (this.environmentService.configuration.remoteAuthority) {
this.startUrlFinder();
} else {
this.contextServiceListener = this._register(this.contextKeyService.onDidChangeContext(e => {
if (e.affectsSome(new Set(forwardedPortsViewEnabled.keys()))) {
this.startUrlFinder();
}
}));
}
this.contextServiceListener = this._register(this.contextKeyService.onDidChangeContext(e => {
if (e.affectsSome(new Set(forwardedPortsViewEnabled.keys()))) {
this.startUrlFinder();
}
}));
}

private isStarted = false;
private startUrlFinder() {
if (!this.isStarted && !forwardedPortsViewEnabled.getValue(this.contextKeyService)) {
return;
}
this.contextServiceListener.dispose();
if (this.contextServiceListener) {
this.contextServiceListener.dispose();
}
this.isStarted = true;
const urlFinder = this._register(new UrlFinder(this.terminalService));
this._register(urlFinder.onDidMatchLocalUrl(async (localUrl) => {
Expand Down

0 comments on commit b0231fd

Please sign in to comment.