Skip to content

Commit ebff1e6

Browse files
committed
use configuration from environment service
1 parent 2a88776 commit ebff1e6

1 file changed

Lines changed: 37 additions & 36 deletions

File tree

  • src/vs/workbench/electron-browser

src/vs/workbench/electron-browser/main.ts

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import { StorageService } from 'vs/platform/storage/node/storageService';
2828
import { LogLevelSetterChannelClient, FollowerLogService } from 'vs/platform/log/common/logIpc';
2929
import { Schemas } from 'vs/base/common/network';
3030
import { sanitizeFilePath } from 'vs/base/common/extpath';
31-
import { basename } from 'vs/base/common/path';
3231
import { GlobalStorageDatabaseChannelClient } from 'vs/platform/storage/node/storageIpc';
3332
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
3433
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
@@ -51,13 +50,16 @@ import { SpdLogService } from 'vs/platform/log/node/spdlogService';
5150
import { SignService } from 'vs/platform/sign/node/signService';
5251
import { ISignService } from 'vs/platform/sign/common/sign';
5352
import { FileUserDataProvider } from 'vs/workbench/services/userData/common/fileUserDataProvider';
53+
import { basename } from 'vs/base/common/resources';
5454

5555
class CodeRendererMain extends Disposable {
5656

5757
private workbench: Workbench;
58+
private readonly environmentService: WorkbenchEnvironmentService;
5859

59-
constructor(private readonly configuration: IWindowConfiguration) {
60+
constructor(configuration: IWindowConfiguration) {
6061
super();
62+
this.environmentService = new WorkbenchEnvironmentService(configuration, configuration.execPath);
6163

6264
this.init();
6365
}
@@ -71,29 +73,29 @@ class CodeRendererMain extends Disposable {
7173
this.reviveUris();
7274

7375
// Setup perf
74-
importEntries(this.configuration.perfEntries);
76+
importEntries(this.environmentService.configuration.perfEntries);
7577

7678
// Browser config
7779
setZoomFactor(webFrame.getZoomFactor()); // Ensure others can listen to zoom level changes
7880
setZoomLevel(webFrame.getZoomLevel(), true /* isTrusted */); // Can be trusted because we are not setting it ourselves (https://github.com/Microsoft/vscode/issues/26151)
79-
setFullscreen(!!this.configuration.fullscreen);
81+
setFullscreen(!!this.environmentService.configuration.fullscreen);
8082

8183
// Keyboard support
8284
KeyboardMapperFactory.INSTANCE._onKeyboardLayoutChanged();
8385
}
8486

8587
private reviveUris() {
86-
if (this.configuration.folderUri) {
87-
this.configuration.folderUri = URI.revive(this.configuration.folderUri);
88+
if (this.environmentService.configuration.folderUri) {
89+
this.environmentService.configuration.folderUri = URI.revive(this.environmentService.configuration.folderUri);
8890
}
8991

90-
if (this.configuration.workspace) {
91-
this.configuration.workspace = reviveWorkspaceIdentifier(this.configuration.workspace);
92+
if (this.environmentService.configuration.workspace) {
93+
this.environmentService.configuration.workspace = reviveWorkspaceIdentifier(this.environmentService.configuration.workspace);
9294
}
9395

94-
const filesToWait = this.configuration.filesToWait;
96+
const filesToWait = this.environmentService.configuration.filesToWait;
9597
const filesToWaitPaths = filesToWait && filesToWait.paths;
96-
[filesToWaitPaths, this.configuration.filesToOpenOrCreate, this.configuration.filesToDiff].forEach(paths => {
98+
[filesToWaitPaths, this.environmentService.configuration.filesToOpenOrCreate, this.environmentService.configuration.filesToDiff].forEach(paths => {
9799
if (Array.isArray(paths)) {
98100
paths.forEach(path => {
99101
if (path.fileUri) {
@@ -130,17 +132,17 @@ class CodeRendererMain extends Disposable {
130132
this._register(instantiationService.createInstance(ElectronWindow));
131133

132134
// Driver
133-
if (this.configuration.driver) {
135+
if (this.environmentService.configuration.driver) {
134136
instantiationService.invokeFunction(async accessor => this._register(await registerWindowDriver(accessor)));
135137
}
136138

137139
// Config Exporter
138-
if (this.configuration['export-default-configuration']) {
140+
if (this.environmentService.configuration['export-default-configuration']) {
139141
instantiationService.createInstance(DefaultConfigurationExportHelper);
140142
}
141143

142144
// Logging
143-
services.logService.trace('workbench configuration', JSON.stringify(this.configuration));
145+
services.logService.trace('workbench configuration', JSON.stringify(this.environmentService.configuration));
144146
}
145147

146148
private onWindowResize(e: Event, retry: boolean): void {
@@ -170,15 +172,14 @@ class CodeRendererMain extends Disposable {
170172
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
171173

172174
// Main Process
173-
const mainProcessService = this._register(new MainProcessService(this.configuration.windowId));
175+
const mainProcessService = this._register(new MainProcessService(this.environmentService.configuration.windowId));
174176
serviceCollection.set(IMainProcessService, mainProcessService);
175177

176178
// Environment
177-
const environmentService = new WorkbenchEnvironmentService(this.configuration, this.configuration.execPath);
178-
serviceCollection.set(IWorkbenchEnvironmentService, environmentService);
179+
serviceCollection.set(IWorkbenchEnvironmentService, this.environmentService);
179180

180181
// Log
181-
const logService = this._register(this.createLogService(mainProcessService, environmentService));
182+
const logService = this._register(this.createLogService(mainProcessService, this.environmentService));
182183
serviceCollection.set(ILogService, logService);
183184

184185
// Remote
@@ -189,7 +190,7 @@ class CodeRendererMain extends Disposable {
189190
const signService = new SignService();
190191
serviceCollection.set(ISignService, signService);
191192

192-
const remoteAgentService = this._register(new RemoteAgentService(this.configuration, environmentService, remoteAuthorityResolverService, signService));
193+
const remoteAgentService = this._register(new RemoteAgentService(this.environmentService.configuration, this.environmentService, remoteAuthorityResolverService, signService));
193194
serviceCollection.set(IRemoteAgentService, remoteAgentService);
194195

195196
// Files
@@ -200,7 +201,7 @@ class CodeRendererMain extends Disposable {
200201
fileService.registerProvider(Schemas.file, diskFileSystemProvider);
201202

202203
// User Data Provider
203-
fileService.registerProvider(Schemas.userData, new FileUserDataProvider(environmentService.appSettingsHome, environmentService.backupHome, diskFileSystemProvider, environmentService));
204+
fileService.registerProvider(Schemas.userData, new FileUserDataProvider(this.environmentService.appSettingsHome, this.environmentService.backupHome, diskFileSystemProvider, this.environmentService));
204205

205206
const connection = remoteAgentService.getConnection();
206207
if (connection) {
@@ -210,10 +211,10 @@ class CodeRendererMain extends Disposable {
210211
}
211212

212213

213-
const payload = await this.resolveWorkspaceInitializationPayload(environmentService);
214+
const payload = await this.resolveWorkspaceInitializationPayload();
214215

215216
const services = await Promise.all([
216-
this.createWorkspaceService(payload, environmentService, fileService, remoteAgentService, logService).then(service => {
217+
this.createWorkspaceService(payload, fileService, remoteAgentService, logService).then(service => {
217218

218219
// Workspace
219220
serviceCollection.set(IWorkspaceContextService, service);
@@ -224,7 +225,7 @@ class CodeRendererMain extends Disposable {
224225
return service;
225226
}),
226227

227-
this.createStorageService(payload, environmentService, logService, mainProcessService).then(service => {
228+
this.createStorageService(payload, logService, mainProcessService).then(service => {
228229

229230
// Storage
230231
serviceCollection.set(IStorageService, service);
@@ -236,25 +237,25 @@ class CodeRendererMain extends Disposable {
236237
return { serviceCollection, logService, storageService: services[1] };
237238
}
238239

239-
private async resolveWorkspaceInitializationPayload(environmentService: IWorkbenchEnvironmentService): Promise<IWorkspaceInitializationPayload> {
240+
private async resolveWorkspaceInitializationPayload(): Promise<IWorkspaceInitializationPayload> {
240241

241242
// Multi-root workspace
242-
if (this.configuration.workspace) {
243-
return this.configuration.workspace;
243+
if (this.environmentService.configuration.workspace) {
244+
return this.environmentService.configuration.workspace;
244245
}
245246

246247
// Single-folder workspace
247248
let workspaceInitializationPayload: IWorkspaceInitializationPayload | undefined;
248-
if (this.configuration.folderUri) {
249-
workspaceInitializationPayload = await this.resolveSingleFolderWorkspaceInitializationPayload(this.configuration.folderUri);
249+
if (this.environmentService.configuration.folderUri) {
250+
workspaceInitializationPayload = await this.resolveSingleFolderWorkspaceInitializationPayload(this.environmentService.configuration.folderUri);
250251
}
251252

252253
// Fallback to empty workspace if we have no payload yet.
253254
if (!workspaceInitializationPayload) {
254255
let id: string;
255-
if (this.configuration.backupPath) {
256-
id = basename(this.configuration.backupPath); // we know the backupPath must be a unique path so we leverage its name as workspace ID
257-
} else if (environmentService.isExtensionDevelopment) {
256+
if (this.environmentService.configuration.backupWorkspaceResource) {
257+
id = basename(this.environmentService.configuration.backupWorkspaceResource); // we know the backupPath must be a unique path so we leverage its name as workspace ID
258+
} else if (this.environmentService.isExtensionDevelopment) {
258259
id = 'ext-dev'; // extension development window never stores backups and is a singleton
259260
} else {
260261
throw new Error('Unexpected window configuration without backupPath');
@@ -309,8 +310,8 @@ class CodeRendererMain extends Disposable {
309310
return;
310311
}
311312

312-
private async createWorkspaceService(payload: IWorkspaceInitializationPayload, environmentService: IWorkbenchEnvironmentService, fileService: FileService, remoteAgentService: IRemoteAgentService, logService: ILogService): Promise<WorkspaceService> {
313-
const workspaceService = new WorkspaceService({ remoteAuthority: this.configuration.remoteAuthority, configurationCache: new ConfigurationCache(environmentService) }, environmentService, fileService, remoteAgentService);
313+
private async createWorkspaceService(payload: IWorkspaceInitializationPayload, fileService: FileService, remoteAgentService: IRemoteAgentService, logService: ILogService): Promise<WorkspaceService> {
314+
const workspaceService = new WorkspaceService({ remoteAuthority: this.environmentService.configuration.remoteAuthority, configurationCache: new ConfigurationCache(this.environmentService) }, this.environmentService, fileService, remoteAgentService);
314315

315316
try {
316317
await workspaceService.initialize(payload);
@@ -324,9 +325,9 @@ class CodeRendererMain extends Disposable {
324325
}
325326
}
326327

327-
private async createStorageService(payload: IWorkspaceInitializationPayload, environmentService: IWorkbenchEnvironmentService, logService: ILogService, mainProcessService: IMainProcessService): Promise<StorageService> {
328+
private async createStorageService(payload: IWorkspaceInitializationPayload, logService: ILogService, mainProcessService: IMainProcessService): Promise<StorageService> {
328329
const globalStorageDatabase = new GlobalStorageDatabaseChannelClient(mainProcessService.getChannel('storage'));
329-
const storageService = new StorageService(globalStorageDatabase, logService, environmentService);
330+
const storageService = new StorageService(globalStorageDatabase, logService, this.environmentService);
330331

331332
try {
332333
await storageService.initialize(payload);
@@ -341,8 +342,8 @@ class CodeRendererMain extends Disposable {
341342
}
342343

343344
private createLogService(mainProcessService: IMainProcessService, environmentService: IWorkbenchEnvironmentService): ILogService {
344-
const spdlogService = new SpdLogService(`renderer${this.configuration.windowId}`, environmentService.logsPath, this.configuration.logLevel);
345-
const consoleLogService = new ConsoleLogService(this.configuration.logLevel);
345+
const spdlogService = new SpdLogService(`renderer${this.environmentService.configuration.windowId}`, environmentService.logsPath, this.environmentService.configuration.logLevel);
346+
const consoleLogService = new ConsoleLogService(this.environmentService.configuration.logLevel);
346347
const logService = new MultiplexLogService([consoleLogService, spdlogService]);
347348
const logLevelClient = new LogLevelSetterChannelClient(mainProcessService.getChannel('loglevel'));
348349

0 commit comments

Comments
 (0)