diff --git a/src/vs/workbench/browser/parts/titlebar/menubarControl.ts b/src/vs/workbench/browser/parts/titlebar/menubarControl.ts index 95086b6f0c8ebc4847e8dc6c0980c072e954cd2b..1f3b424acb5602bd754679396fb8c5b19d7def31 100644 --- a/src/vs/workbench/browser/parts/titlebar/menubarControl.ts +++ b/src/vs/workbench/browser/parts/titlebar/menubarControl.ts @@ -449,7 +449,7 @@ export class CustomMenubarControl extends MenubarControl { case StateType.Idle: return new Action('update.check', nls.localize({ key: 'checkForUpdates', comment: ['&& denotes a mnemonic'] }, "Check for &&Updates..."), undefined, true, () => - this.updateService.checkForUpdates(this.environmentService.configuration.sessionId)); + this.updateService.checkForUpdates(this.environmentService.sessionId)); case StateType.CheckingForUpdates: return new Action('update.checking', nls.localize('checkingForUpdates', "Checking for Updates..."), undefined, false); diff --git a/src/vs/workbench/contrib/configExporter/electron-sandbox/configurationExportHelper.contribution.ts b/src/vs/workbench/contrib/configExporter/electron-sandbox/configurationExportHelper.contribution.ts index 8d2753c0d3b3e0dd28fa419a1385d9424fe2dcf0..e780491f3cf3d7d7601cdc2e68f8f7275408ad3b 100644 --- a/src/vs/workbench/contrib/configExporter/electron-sandbox/configurationExportHelper.contribution.ts +++ b/src/vs/workbench/contrib/configExporter/electron-sandbox/configurationExportHelper.contribution.ts @@ -17,7 +17,7 @@ export class ExtensionPoints implements IWorkbenchContribution { @INativeWorkbenchEnvironmentService environmentService: INativeWorkbenchEnvironmentService ) { // Config Exporter - if (environmentService.configuration['export-default-configuration']) { + if (environmentService.args['export-default-configuration']) { instantiationService.createInstance(DefaultConfigurationExportHelper); } } diff --git a/src/vs/workbench/contrib/update/browser/update.ts b/src/vs/workbench/contrib/update/browser/update.ts index 8a140af98ff7a140557f7bbace32ea11def5f057..8bb2eb0eb3c9d1e51dafa75ccfb8ae912b17be7b 100644 --- a/src/vs/workbench/contrib/update/browser/update.ts +++ b/src/vs/workbench/contrib/update/browser/update.ts @@ -224,7 +224,7 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu case StateType.Idle: if (state.error) { this.onError(state.error); - } else if (this.state.type === StateType.CheckingForUpdates && this.state.context === this.environmentService.configuration.sessionId) { + } else if (this.state.type === StateType.CheckingForUpdates && this.state.context === this.environmentService.sessionId) { this.onUpdateNotAvailable(); } break; @@ -409,7 +409,7 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu } private registerGlobalActivityActions(): void { - CommandsRegistry.registerCommand('update.check', () => this.updateService.checkForUpdates(this.environmentService.configuration.sessionId)); + CommandsRegistry.registerCommand('update.check', () => this.updateService.checkForUpdates(this.environmentService.sessionId)); MenuRegistry.appendMenuItem(MenuId.GlobalActivity, { group: '6_update', command: { @@ -543,7 +543,7 @@ export class CheckForVSCodeUpdateAction extends Action { } run(): Promise { - return this.updateService.checkForUpdates(this.environmentService.configuration.sessionId); + return this.updateService.checkForUpdates(this.environmentService.sessionId); } } diff --git a/src/vs/workbench/electron-browser/desktop.main.ts b/src/vs/workbench/electron-browser/desktop.main.ts index 1d16963d44d098b96ea17c37c1cca91c6b5aaafc..42115bba46d4388d941f096f8af041b0fe14afe4 100644 --- a/src/vs/workbench/electron-browser/desktop.main.ts +++ b/src/vs/workbench/electron-browser/desktop.main.ts @@ -71,27 +71,27 @@ class DesktopMain extends Disposable { this.reviveUris(); // Setup perf - importEntries(this.environmentService.configuration.perfEntries); + importEntries(this.configuration.perfEntries); // Browser config const zoomLevel = this.configuration.zoomLevel || 0; setZoomFactor(zoomLevelToZoomFactor(zoomLevel)); setZoomLevel(zoomLevel, true /* isTrusted */); - setFullscreen(!!this.environmentService.configuration.fullscreen); + setFullscreen(!!this.configuration.fullscreen); } private reviveUris() { - if (this.environmentService.configuration.folderUri) { - this.environmentService.configuration.folderUri = URI.revive(this.environmentService.configuration.folderUri); + if (this.configuration.folderUri) { + this.configuration.folderUri = URI.revive(this.configuration.folderUri); } - if (this.environmentService.configuration.workspace) { - this.environmentService.configuration.workspace = reviveWorkspaceIdentifier(this.environmentService.configuration.workspace); + if (this.configuration.workspace) { + this.configuration.workspace = reviveWorkspaceIdentifier(this.configuration.workspace); } - const filesToWait = this.environmentService.configuration.filesToWait; + const filesToWait = this.configuration.filesToWait; const filesToWaitPaths = filesToWait?.paths; - [filesToWaitPaths, this.environmentService.configuration.filesToOpenOrCreate, this.environmentService.configuration.filesToDiff].forEach(paths => { + [filesToWaitPaths, this.configuration.filesToOpenOrCreate, this.configuration.filesToDiff].forEach(paths => { if (Array.isArray(paths)) { paths.forEach(path => { if (path.fileUri) { @@ -125,12 +125,12 @@ class DesktopMain extends Disposable { this._register(instantiationService.createInstance(NativeWindow)); // Driver - if (this.environmentService.configuration.driver) { + if (this.configuration.driver) { instantiationService.invokeFunction(async accessor => this._register(await registerWindowDriver(accessor, this.configuration.windowId))); } // Logging - services.logService.trace('workbench configuration', JSON.stringify(this.environmentService.configuration)); + services.logService.trace('workbench configuration', JSON.stringify(this.configuration)); } private registerListeners(workbench: Workbench, storageService: NativeStorageService): void { @@ -231,7 +231,7 @@ class DesktopMain extends Disposable { fileService.registerProvider(Schemas.file, diskFileSystemProvider); // User Data Provider - fileService.registerProvider(Schemas.userData, new FileUserDataProvider(this.environmentService.appSettingsHome, this.environmentService.configuration.backupPath ? URI.file(this.environmentService.configuration.backupPath) : undefined, diskFileSystemProvider, this.environmentService, logService)); + fileService.registerProvider(Schemas.userData, new FileUserDataProvider(this.environmentService.appSettingsHome, this.configuration.backupPath ? URI.file(this.configuration.backupPath) : undefined, diskFileSystemProvider, this.environmentService, logService)); // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -299,14 +299,14 @@ class DesktopMain extends Disposable { private async resolveWorkspaceInitializationPayload(resourceIdentityService: IResourceIdentityService): Promise { // Multi-root workspace - if (this.environmentService.configuration.workspace) { - return this.environmentService.configuration.workspace; + if (this.configuration.workspace) { + return this.configuration.workspace; } // Single-folder workspace let workspaceInitializationPayload: IWorkspaceInitializationPayload | undefined; - if (this.environmentService.configuration.folderUri) { - workspaceInitializationPayload = await this.resolveSingleFolderWorkspaceInitializationPayload(this.environmentService.configuration.folderUri, resourceIdentityService); + if (this.configuration.folderUri) { + workspaceInitializationPayload = await this.resolveSingleFolderWorkspaceInitializationPayload(this.configuration.folderUri, resourceIdentityService); } // Fallback to empty workspace if we have no payload yet. diff --git a/src/vs/workbench/electron-sandbox/desktop.main.ts b/src/vs/workbench/electron-sandbox/desktop.main.ts index 6fe191f5a5b3cc93ce4755f7c51d91c535d2a822..a5536518ca66f48a39fe105e10c1833b8e429547 100644 --- a/src/vs/workbench/electron-sandbox/desktop.main.ts +++ b/src/vs/workbench/electron-sandbox/desktop.main.ts @@ -52,27 +52,27 @@ class DesktopMain extends Disposable { this.reviveUris(); // Setup perf - importEntries(this.environmentService.configuration.perfEntries); + importEntries(this.configuration.perfEntries); // Browser config const zoomLevel = this.configuration.zoomLevel || 0; setZoomFactor(zoomLevelToZoomFactor(zoomLevel)); setZoomLevel(zoomLevel, true /* isTrusted */); - setFullscreen(!!this.environmentService.configuration.fullscreen); + setFullscreen(!!this.configuration.fullscreen); } private reviveUris() { - if (this.environmentService.configuration.folderUri) { - this.environmentService.configuration.folderUri = URI.revive(this.environmentService.configuration.folderUri); + if (this.configuration.folderUri) { + this.configuration.folderUri = URI.revive(this.configuration.folderUri); } - if (this.environmentService.configuration.workspace) { - this.environmentService.configuration.workspace = reviveWorkspaceIdentifier(this.environmentService.configuration.workspace); + if (this.configuration.workspace) { + this.configuration.workspace = reviveWorkspaceIdentifier(this.configuration.workspace); } - const filesToWait = this.environmentService.configuration.filesToWait; + const filesToWait = this.configuration.filesToWait; const filesToWaitPaths = filesToWait?.paths; - [filesToWaitPaths, this.environmentService.configuration.filesToOpenOrCreate, this.environmentService.configuration.filesToDiff].forEach(paths => { + [filesToWaitPaths, this.configuration.filesToOpenOrCreate, this.configuration.filesToDiff].forEach(paths => { if (Array.isArray(paths)) { paths.forEach(path => { if (path.fileUri) { @@ -106,7 +106,7 @@ class DesktopMain extends Disposable { this._register(instantiationService.createInstance(NativeWindow)); // Logging - services.logService.trace('workbench configuration', JSON.stringify(this.environmentService.configuration)); + services.logService.trace('workbench configuration', JSON.stringify(this.configuration)); } private registerListeners(workbench: Workbench, storageService: SimpleStorageService): void { diff --git a/src/vs/workbench/electron-sandbox/sandbox.simpleservices.ts b/src/vs/workbench/electron-sandbox/sandbox.simpleservices.ts index d57009a5a251ac5815c04e4f76bacef3e518a575..f6523fccb8c882e909291484354154474ab52978 100644 --- a/src/vs/workbench/electron-sandbox/sandbox.simpleservices.ts +++ b/src/vs/workbench/electron-sandbox/sandbox.simpleservices.ts @@ -89,6 +89,9 @@ export class SimpleNativeWorkbenchEnvironmentService implements INativeWorkbench get backupWorkspaceHome(): URI { return joinPath(this.userRoamingDataHome, 'Backups', 'workspace'); } get logsPath(): string { return joinPath(this.userRoamingDataHome, 'logs').path; } + sessionId = this.configuration.sessionId; + machineId = this.configuration.machineId; + options?: IWorkbenchConstructionOptions | undefined; logExtensionHostCommunication?: boolean | undefined; extensionEnabledProposedApi?: string[] | undefined; diff --git a/src/vs/workbench/services/environment/browser/environmentService.ts b/src/vs/workbench/services/environment/browser/environmentService.ts index 759fa8a0d6512fe744e40af3330ad795afb8094a..e87515dd587badb5368bea5c069f2aae4fce9897 100644 --- a/src/vs/workbench/services/environment/browser/environmentService.ts +++ b/src/vs/workbench/services/environment/browser/environmentService.ts @@ -104,6 +104,9 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment @memoize get remoteAuthority(): string | undefined { return this.options.remoteAuthority; } + @memoize + get sessionId(): string { return this.configuration.sessionId; } + @memoize get isBuilt(): boolean { return !!this.productService.commit; } @@ -231,6 +234,8 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment get verbose(): boolean { return this.payload?.get('verbose') === 'true'; } get logExtensionHostCommunication(): boolean { return this.payload?.get('logExtensionHostCommunication') === 'true'; } + get skipReleaseNotes(): boolean { return false; } + private payload: Map | undefined; constructor( @@ -286,6 +291,4 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment return extensionHostDebugEnvironment; } - - get skipReleaseNotes(): boolean { return false; } } diff --git a/src/vs/workbench/services/environment/common/environmentService.ts b/src/vs/workbench/services/environment/common/environmentService.ts index 860a03fcf356c1f9aac025401b55a8d6daa9ff63..efa7ea15b2fdbc8ad95ec1b5b1a4a06b1661b38e 100644 --- a/src/vs/workbench/services/environment/common/environmentService.ts +++ b/src/vs/workbench/services/environment/common/environmentService.ts @@ -32,6 +32,8 @@ export interface IWorkbenchEnvironmentService extends IEnvironmentService { readonly remoteAuthority?: string; + readonly sessionId: string; + readonly logFile: URI; readonly backupWorkspaceHome?: URI; diff --git a/src/vs/workbench/services/environment/electron-browser/environmentService.ts b/src/vs/workbench/services/environment/electron-browser/environmentService.ts index f0909420a1f50d2c001ed4fce03b7ae0be1d75c3..ae4bc8393e7c1c0e2928bb07a57fd7ea74851ef0 100644 --- a/src/vs/workbench/services/environment/electron-browser/environmentService.ts +++ b/src/vs/workbench/services/environment/electron-browser/environmentService.ts @@ -16,23 +16,28 @@ export class NativeWorkbenchEnvironmentService extends NativeEnvironmentService declare readonly _serviceBrand: undefined; @memoize - get webviewExternalEndpoint(): string { - const baseEndpoint = 'https://{{uuid}}.vscode-webview-test.com/{{commit}}'; + get machineId() { return this.configuration.machineId; } - return baseEndpoint.replace('{{commit}}', this.productService.commit || '0d728c31ebdf03869d2687d9be0b017667c9ff37'); - } + @memoize + get sessionId() { return this.configuration.sessionId; } @memoize - get webviewResourceRoot(): string { return `${Schemas.vscodeWebviewResource}://{{uuid}}/{{resource}}`; } + get remoteAuthority() { return this.configuration.remoteAuthority; } @memoize - get webviewCspSource(): string { return `${Schemas.vscodeWebviewResource}:`; } + get execPath() { return this.configuration.execPath; } @memoize get userRoamingDataHome(): URI { return this.appSettingsHome.with({ scheme: Schemas.userData }); } - // Do not memoize as `backupPath` can change in configuration - get backupWorkspaceHome(): URI | undefined { return this.configuration.backupPath ? URI.file(this.configuration.backupPath).with({ scheme: this.userRoamingDataHome.scheme }) : undefined; } + // Do NOT! memoize as `backupPath` can change in configuration + get backupWorkspaceHome(): URI | undefined { + if (this.configuration.backupPath) { + return URI.file(this.configuration.backupPath).with({ scheme: this.userRoamingDataHome.scheme }); + } + + return undefined; + } @memoize get logFile(): URI { return URI.file(join(this.logsPath, `renderer${this.configuration.windowId}.log`)); } @@ -40,6 +45,19 @@ export class NativeWorkbenchEnvironmentService extends NativeEnvironmentService @memoize get extHostLogsPath(): URI { return URI.file(join(this.logsPath, `exthost${this.configuration.windowId}`)); } + @memoize + get webviewExternalEndpoint(): string { + const baseEndpoint = 'https://{{uuid}}.vscode-webview-test.com/{{commit}}'; + + return baseEndpoint.replace('{{commit}}', this.productService.commit || '0d728c31ebdf03869d2687d9be0b017667c9ff37'); + } + + @memoize + get webviewResourceRoot(): string { return `${Schemas.vscodeWebviewResource}://{{uuid}}/{{resource}}`; } + + @memoize + get webviewCspSource(): string { return `${Schemas.vscodeWebviewResource}:`; } + @memoize get skipReleaseNotes(): boolean { return !!this.args['skip-release-notes']; } @@ -59,10 +77,6 @@ export class NativeWorkbenchEnvironmentService extends NativeEnvironmentService return undefined; } - readonly execPath = this.configuration.execPath; - - readonly remoteAuthority = this.configuration.remoteAuthority; - constructor( readonly configuration: INativeWorkbenchConfiguration, private readonly productService: IProductService diff --git a/src/vs/workbench/services/environment/electron-sandbox/environmentService.ts b/src/vs/workbench/services/environment/electron-sandbox/environmentService.ts index 97b80183da6460379898cc4762d54943afb8a68a..46c35f5416a41d984708cd37efdbaf93e460c7a5 100644 --- a/src/vs/workbench/services/environment/electron-sandbox/environmentService.ts +++ b/src/vs/workbench/services/environment/electron-sandbox/environmentService.ts @@ -21,6 +21,8 @@ export interface INativeWorkbenchEnvironmentService extends IWorkbenchEnvironmen readonly configuration: INativeWorkbenchConfiguration; + readonly machineId: string; + readonly crashReporterDirectory?: string; readonly crashReporterId?: string; diff --git a/src/vs/workbench/services/telemetry/electron-browser/telemetryService.ts b/src/vs/workbench/services/telemetry/electron-browser/telemetryService.ts index 048318b0cd617109250fcafa8e70dc606047351f..9ae3f282d848cd8f92f07a18cb4d84d6d0d98c7d 100644 --- a/src/vs/workbench/services/telemetry/electron-browser/telemetryService.ts +++ b/src/vs/workbench/services/telemetry/electron-browser/telemetryService.ts @@ -39,7 +39,7 @@ export class TelemetryService extends Disposable implements ITelemetryService { const channel = sharedProcessService.getChannel('telemetryAppender'); const config: ITelemetryServiceConfig = { appender: combinedAppender(new TelemetryAppenderClient(channel), new LogAppender(logService)), - commonProperties: resolveWorkbenchCommonProperties(storageService, productService.commit, productService.version, environmentService.configuration.machineId, productService.msftInternalDomains, environmentService.installSourcePath, environmentService.remoteAuthority), + commonProperties: resolveWorkbenchCommonProperties(storageService, productService.commit, productService.version, environmentService.machineId, productService.msftInternalDomains, environmentService.installSourcePath, environmentService.remoteAuthority), piiPaths: environmentService.extensionsPath ? [environmentService.appRoot, environmentService.extensionsPath] : [environmentService.appRoot], sendErrorTelemetry: true };