mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-03 15:01:57 +01:00
🐛 linux BrowserWindow don't inherit env
This commit is contained in:
@@ -51,6 +51,9 @@ function main() {
|
||||
const args = parseURLQueryArgs();
|
||||
const configuration = JSON.parse(args['config'] || '{}') || {};
|
||||
|
||||
// Correctly inherit the parent's environment
|
||||
assign(process.env, configuration.userEnv);
|
||||
|
||||
// Get the nls configuration into the process.env as early as possible.
|
||||
var nlsConfig = { availableLanguages: {} };
|
||||
const config = process.env['VSCODE_NLS_CONFIG'];
|
||||
|
||||
@@ -36,6 +36,7 @@ import { ActiveWindowManager } from 'vs/code/common/windows';
|
||||
import { ipcRenderer } from 'electron';
|
||||
|
||||
interface ISharedProcessInitData {
|
||||
sharedIPCHandle: string;
|
||||
args: ParsedArgs;
|
||||
}
|
||||
|
||||
@@ -142,13 +143,17 @@ function setupIPC(hook: string): TPromise<Server> {
|
||||
return setup(true);
|
||||
}
|
||||
|
||||
function handshake(): TPromise<ISharedProcessInitData> {
|
||||
function startHandshake(): TPromise<ISharedProcessInitData> {
|
||||
return new TPromise<ISharedProcessInitData>((c, e) => {
|
||||
ipcRenderer.once('handshake', (_, r) => c(r));
|
||||
ipcRenderer.send('handshake');
|
||||
ipcRenderer.once('handshake:hey there', (_, r) => c(r));
|
||||
ipcRenderer.send('handshake:hello');
|
||||
});
|
||||
}
|
||||
|
||||
setupIPC(process.env['VSCODE_SHARED_IPC_HOOK'])
|
||||
.then(server => handshake()
|
||||
.then(data => main(server, data)));
|
||||
function handshake(): TPromise<void> {
|
||||
return startHandshake()
|
||||
.then((data) => setupIPC(data.sharedIPCHandle).then(server => main(server, data)))
|
||||
.then(() => ipcRenderer.send('handshake:im ready'));
|
||||
}
|
||||
|
||||
handshake();
|
||||
|
||||
@@ -142,9 +142,7 @@ function main(accessor: ServicesAccessor, mainIpcServer: Server, userEnv: platfo
|
||||
const electronIpcServer = new ElectronIPCServer();
|
||||
|
||||
// Spawn shared process
|
||||
const initData = { args: environmentService.args };
|
||||
|
||||
const sharedProcess = new SharedProcess(initData, environmentService.appRoot, environmentService.nodeCachedDataDir);
|
||||
const sharedProcess = new SharedProcess(environmentService, userEnv);
|
||||
const sharedProcessClient = sharedProcess.onReady
|
||||
.then(() => connect(environmentService.sharedIPCHandle, 'main'));
|
||||
|
||||
@@ -395,7 +393,6 @@ function start(): void {
|
||||
const instanceEnv: typeof process.env = {
|
||||
VSCODE_PID: String(process.pid),
|
||||
VSCODE_IPC_HOOK: environmentService.mainIPCHandle,
|
||||
VSCODE_SHARED_IPC_HOOK: environmentService.sharedIPCHandle,
|
||||
VSCODE_NLS_CONFIG: process.env['VSCODE_NLS_CONFIG']
|
||||
};
|
||||
|
||||
|
||||
@@ -6,14 +6,11 @@
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
import { memoize } from 'vs/base/common/decorators';
|
||||
import { IDisposable, toDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IProcessEnvironment } from 'vs/base/common/platform';
|
||||
import { BrowserWindow, ipcMain } from 'electron';
|
||||
|
||||
export interface ISharedProcessInitData {
|
||||
args: ParsedArgs;
|
||||
}
|
||||
|
||||
export class SharedProcess {
|
||||
|
||||
private window: Electron.BrowserWindow;
|
||||
@@ -22,7 +19,11 @@ export class SharedProcess {
|
||||
@memoize
|
||||
get onReady(): TPromise<void> {
|
||||
this.window = new BrowserWindow({ show: false });
|
||||
const config = assign({ appRoot: this.appRoot, nodeCachedDataDir: this.nodeCachedDataDir });
|
||||
const config = assign({
|
||||
appRoot: this.environmentService.appRoot,
|
||||
nodeCachedDataDir: this.environmentService.nodeCachedDataDir,
|
||||
userEnv: this.userEnv
|
||||
});
|
||||
|
||||
const url = `${require.toUrl('vs/code/electron-browser/sharedProcess.html')}?config=${encodeURIComponent(JSON.stringify(config))}`;
|
||||
this.window.loadURL(url);
|
||||
@@ -47,17 +48,20 @@ export class SharedProcess {
|
||||
}));
|
||||
|
||||
return new TPromise<void>((c, e) => {
|
||||
ipcMain.once('handshake', ({ sender }) => {
|
||||
sender.send('handshake', this.initData);
|
||||
c(null);
|
||||
ipcMain.once('handshake:hello', ({ sender }) => {
|
||||
sender.send('handshake:hey there', {
|
||||
sharedIPCHandle: this.environmentService.sharedIPCHandle,
|
||||
args: this.environmentService.args
|
||||
});
|
||||
|
||||
sender.once('handshake:im ready', () => c(null));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
constructor(
|
||||
private initData: ISharedProcessInitData,
|
||||
private appRoot: string,
|
||||
private nodeCachedDataDir: string
|
||||
private environmentService: IEnvironmentService,
|
||||
private userEnv: IProcessEnvironment
|
||||
) { }
|
||||
|
||||
toggle(): void {
|
||||
|
||||
Reference in New Issue
Block a user