Skip to content

Commit 1e960d5

Browse files
committed
Set Electron session's proxy from user setting (fixes microsoft#94148)
1 parent d5e12a1 commit 1e960d5

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/vs/code/electron-main/window.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ export class CodeWindow extends Disposable implements ICodeWindow {
118118

119119
private readonly touchBarGroups: TouchBarSegmentedControl[];
120120

121+
private currentHttpProxy?: string;
122+
121123
constructor(
122124
config: IWindowCreationOptions,
123125
@ILogService private readonly logService: ILogService,
@@ -594,6 +596,16 @@ export class CodeWindow extends Disposable implements ICodeWindow {
594596
this.currentMenuBarVisibility = newMenuBarVisibility;
595597
this.setMenuBarVisibility(newMenuBarVisibility);
596598
}
599+
// Do not set to empty configuration at startup if setting is empty to not override configuration through CLI options:
600+
const newHttpProxy = (this.configurationService.getValue<string>('http.proxy') || '').trim() || undefined;
601+
if (newHttpProxy !== this.currentHttpProxy) {
602+
this.currentHttpProxy = newHttpProxy;
603+
this._win.webContents.session.setProxy({
604+
proxyRules: newHttpProxy || '',
605+
proxyBypassRules: '',
606+
pacScript: '',
607+
});
608+
}
597609
}
598610

599611
addTabbedWindow(window: ICodeWindow): void {

0 commit comments

Comments
 (0)