diff --git a/src/vs/workbench/browser/layout.ts b/src/vs/workbench/browser/layout.ts index acebcd3e9f4..55e517319df 100644 --- a/src/vs/workbench/browser/layout.ts +++ b/src/vs/workbench/browser/layout.ts @@ -613,7 +613,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi } // Then check for files to open, create or diff from main side - const { filesToOpenOrCreate, filesToDiff } = this.environmentService.configuration; + const { filesToOpenOrCreate, filesToDiff } = this.environmentService; if (filesToOpenOrCreate || filesToDiff) { return { filesToOpenOrCreate, filesToDiff }; } diff --git a/src/vs/workbench/contrib/remote/electron-sandbox/remote.contribution.ts b/src/vs/workbench/contrib/remote/electron-sandbox/remote.contribution.ts index 6c88e74721e..172063360b9 100644 --- a/src/vs/workbench/contrib/remote/electron-sandbox/remote.contribution.ts +++ b/src/vs/workbench/contrib/remote/electron-sandbox/remote.contribution.ts @@ -137,7 +137,7 @@ class RemoteEmptyWorkbenchPresentation extends Disposable implements IWorkbenchC return shouldShowExplorer(); } - const { remoteAuthority, filesToDiff, filesToOpenOrCreate, filesToWait } = environmentService.configuration; + const { remoteAuthority, filesToDiff, filesToOpenOrCreate, filesToWait } = environmentService; if (remoteAuthority && contextService.getWorkbenchState() === WorkbenchState.EMPTY && !filesToDiff?.length && !filesToOpenOrCreate?.length && !filesToWait) { remoteAuthorityResolverService.resolveAuthority(remoteAuthority).then(() => { if (shouldShowExplorer()) { diff --git a/src/vs/workbench/contrib/tags/electron-sandbox/workspaceTagsService.ts b/src/vs/workbench/contrib/tags/electron-sandbox/workspaceTagsService.ts index ecc77eb8a0f..b7891c758d4 100644 --- a/src/vs/workbench/contrib/tags/electron-sandbox/workspaceTagsService.ts +++ b/src/vs/workbench/contrib/tags/electron-sandbox/workspaceTagsService.ts @@ -372,7 +372,7 @@ export class WorkspaceTagsService implements IWorkspaceTagsService { "workspace.npm.playwright-core" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }, "workspace.npm.playwright-chromium" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }, "workspace.npm.playwright-firefox" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }, - "workspace.npm.playwright-webkit" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }, + "workspace.npm.playwright-webkit" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }, "workspace.npm.cypress" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }, "workspace.npm.nightwatch" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }, "workspace.npm.protractor" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }, @@ -572,7 +572,7 @@ export class WorkspaceTagsService implements IWorkspaceTagsService { tags['workspace.id'] = await this.getTelemetryWorkspaceId(workspace, state); - const { filesToOpenOrCreate, filesToDiff } = this.environmentService.configuration; + const { filesToOpenOrCreate, filesToDiff } = this.environmentService; tags['workbench.filesToOpenOrCreate'] = filesToOpenOrCreate && filesToOpenOrCreate.length || 0; tags['workbench.filesToDiff'] = filesToDiff && filesToDiff.length || 0; @@ -813,7 +813,7 @@ export class WorkspaceTagsService implements IWorkspaceTagsService { } private findFolder(): URI | undefined { - const { filesToOpenOrCreate, filesToDiff } = this.environmentService.configuration; + const { filesToOpenOrCreate, filesToDiff } = this.environmentService; if (filesToOpenOrCreate && filesToOpenOrCreate.length) { return this.parentURI(filesToOpenOrCreate[0].fileUri); } else if (filesToDiff && filesToDiff.length) { diff --git a/src/vs/workbench/contrib/telemetry/browser/telemetry.contribution.ts b/src/vs/workbench/contrib/telemetry/browser/telemetry.contribution.ts index 8615fce5375..bc7e49a15ed 100644 --- a/src/vs/workbench/contrib/telemetry/browser/telemetry.contribution.ts +++ b/src/vs/workbench/contrib/telemetry/browser/telemetry.contribution.ts @@ -61,7 +61,7 @@ export class TelemetryContribution extends Disposable implements IWorkbenchContr ) { super(); - const { filesToOpenOrCreate, filesToDiff } = environmentService.configuration; + const { filesToOpenOrCreate, filesToDiff } = environmentService; const activeViewlet = paneCompositeService.getActivePaneComposite(ViewContainerLocation.Sidebar); type WindowSizeFragment = { diff --git a/src/vs/workbench/contrib/terminal/test/browser/terminalProfileService.test.ts b/src/vs/workbench/contrib/terminal/test/browser/terminalProfileService.test.ts index 53aab44a21a..5fb8a0c76ec 100644 --- a/src/vs/workbench/contrib/terminal/test/browser/terminalProfileService.test.ts +++ b/src/vs/workbench/contrib/terminal/test/browser/terminalProfileService.test.ts @@ -157,7 +157,7 @@ suite('TerminalProfileService', () => { remoteAgentService = new TestRemoteAgentService(); terminalInstanceService = new TestTerminalInstanceService(); extensionService = new TestTerminalExtensionService(); - environmentService = { configuration: {}, remoteAuthority: undefined } as IWorkbenchEnvironmentService; + environmentService = { remoteAuthority: undefined } as IWorkbenchEnvironmentService; instantiationService = new TestInstantiationService(); let themeService = new TestThemeService(); @@ -258,7 +258,7 @@ suite('TerminalProfileService', () => { }); test('should get profiles from remoteTerminalService when there is a remote authority', async () => { - environmentService = { configuration: {}, remoteAuthority: 'fakeremote' } as IWorkbenchEnvironmentService; + environmentService = { remoteAuthority: 'fakeremote' } as IWorkbenchEnvironmentService; instantiationService.stub(IWorkbenchEnvironmentService, environmentService); terminalProfileService = instantiationService.createInstance(TestTerminalProfileService); await terminalProfileService.hasRefreshedProfiles; diff --git a/src/vs/workbench/electron-sandbox/desktop.main.ts b/src/vs/workbench/electron-sandbox/desktop.main.ts index 70bfea47760..d6010d9d253 100644 --- a/src/vs/workbench/electron-sandbox/desktop.main.ts +++ b/src/vs/workbench/electron-sandbox/desktop.main.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import product from 'vs/platform/product/common/product'; -import { zoomLevelToZoomFactor } from 'vs/platform/windows/common/windows'; +import { INativeWindowConfiguration, zoomLevelToZoomFactor } from 'vs/platform/windows/common/windows'; import { Workbench } from 'vs/workbench/browser/workbench'; import { NativeWindow } from 'vs/workbench/electron-sandbox/window'; import { setZoomLevel, setZoomFactor, setFullscreen } from 'vs/base/browser/browser'; @@ -12,7 +12,7 @@ import { domContentLoaded } from 'vs/base/browser/dom'; import { onUnexpectedError } from 'vs/base/common/errors'; import { URI } from 'vs/base/common/uri'; import { WorkspaceService } from 'vs/workbench/services/configuration/browser/configurationService'; -import { INativeWorkbenchConfiguration, INativeWorkbenchEnvironmentService, NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; +import { INativeWorkbenchEnvironmentService, NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; import { isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier, IWorkspaceInitializationPayload, reviveIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { ILoggerService, ILogService } from 'vs/platform/log/common/log'; @@ -55,7 +55,7 @@ import { FileUserDataProvider } from 'vs/platform/userData/common/fileUserDataPr export class DesktopMain extends Disposable { constructor( - private readonly configuration: INativeWorkbenchConfiguration + private readonly configuration: INativeWindowConfiguration ) { super(); @@ -174,11 +174,11 @@ export class DesktopMain extends Disposable { // Logger const logLevelChannelClient = new LogLevelChannelClient(mainProcessService.getChannel('logLevel')); - const loggerService = new LoggerChannelClient(environmentService.configuration.logLevel, logLevelChannelClient.onDidChangeLogLevel, mainProcessService.getChannel('logger')); + const loggerService = new LoggerChannelClient(this.configuration.logLevel, logLevelChannelClient.onDidChangeLogLevel, mainProcessService.getChannel('logger')); serviceCollection.set(ILoggerService, loggerService); // Log - const logService = this._register(new NativeLogService(`renderer${this.configuration.windowId}`, environmentService.configuration.logLevel, loggerService, logLevelChannelClient, environmentService)); + const logService = this._register(new NativeLogService(`renderer${this.configuration.windowId}`, this.configuration.logLevel, loggerService, logLevelChannelClient, environmentService)); serviceCollection.set(ILogService, logService); // Shared Process @@ -372,7 +372,7 @@ export class DesktopMain extends Disposable { } } -export function main(configuration: INativeWorkbenchConfiguration): Promise { +export function main(configuration: INativeWindowConfiguration): Promise { const workbench = new DesktopMain(configuration); return workbench.open(); diff --git a/src/vs/workbench/electron-sandbox/window.ts b/src/vs/workbench/electron-sandbox/window.ts index 763c8d02384..60167bc3254 100644 --- a/src/vs/workbench/electron-sandbox/window.ts +++ b/src/vs/workbench/electron-sandbox/window.ts @@ -263,7 +263,7 @@ export class NativeWindow extends Disposable { this._register(this.editorService.onDidVisibleEditorsChange(() => this.onDidChangeVisibleEditors())); // Listen to editor closing (if we run with --wait) - const filesToWait = this.environmentService.configuration.filesToWait; + const filesToWait = this.environmentService.filesToWait; if (filesToWait) { this.trackClosedWaitFiles(filesToWait.waitMarkerFileUri, coalesce(filesToWait.paths.map(path => path.fileUri))); } @@ -310,7 +310,7 @@ export class NativeWindow extends Disposable { Event.map(Event.filter(this.nativeHostService.onDidUnmaximizeWindow, id => id === this.nativeHostService.windowId), () => false) )(e => this.onDidChangeWindowMaximized(e))); - this.onDidChangeWindowMaximized(this.environmentService.configuration.maximized ?? false); + this.onDidChangeWindowMaximized(this.environmentService.window.maximized ?? false); // Lifecycle this._register(this.lifecycleService.onBeforeShutdownError(e => this.onBeforeShutdownError(e))); diff --git a/src/vs/workbench/services/accessibility/electron-sandbox/accessibilityService.ts b/src/vs/workbench/services/accessibility/electron-sandbox/accessibilityService.ts index c3004ecaecb..11250faa762 100644 --- a/src/vs/workbench/services/accessibility/electron-sandbox/accessibilityService.ts +++ b/src/vs/workbench/services/accessibility/electron-sandbox/accessibilityService.ts @@ -37,7 +37,7 @@ export class NativeAccessibilityService extends AccessibilityService implements @INativeHostService private readonly nativeHostService: INativeHostService ) { super(contextKeyService, configurationService); - this.setAccessibilitySupport(environmentService.configuration.accessibilitySupport ? AccessibilitySupport.Enabled : AccessibilitySupport.Disabled); + this.setAccessibilitySupport(environmentService.window.accessibilitySupport ? AccessibilitySupport.Enabled : AccessibilitySupport.Disabled); } override async alwaysUnderlineAccessKeys(): Promise { diff --git a/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts b/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts index cd7dd738abb..9fdd805bf15 100644 --- a/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts +++ b/src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts @@ -26,7 +26,7 @@ import { NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environ import { IPathService } from 'vs/workbench/services/path/common/pathService'; import { TestEditorService, TestProductService, TestQuickInputService } from 'vs/workbench/test/browser/workbenchTestServices'; import { TestContextService } from 'vs/workbench/test/common/workbenchTestServices'; -import { TestWorkbenchConfiguration } from 'vs/workbench/test/electron-browser/workbenchTestServices'; +import { TestNativeWindowConfiguration } from 'vs/workbench/test/electron-browser/workbenchTestServices'; const mockLineNumber = 10; class TestEditorServiceWithActiveEditor extends TestEditorService { @@ -746,6 +746,6 @@ class MockInputsConfigurationService extends TestConfigurationService { class MockWorkbenchEnvironmentService extends NativeWorkbenchEnvironmentService { constructor(public userEnv: platform.IProcessEnvironment) { - super({ ...TestWorkbenchConfiguration, userEnv }, TestProductService); + super({ ...TestNativeWindowConfiguration, userEnv }, TestProductService); } } diff --git a/src/vs/workbench/services/environment/browser/environmentService.ts b/src/vs/workbench/services/environment/browser/environmentService.ts index 57afef9411c..3c8df7db731 100644 --- a/src/vs/workbench/services/environment/browser/environmentService.ts +++ b/src/vs/workbench/services/environment/browser/environmentService.ts @@ -6,9 +6,8 @@ import { Schemas } from 'vs/base/common/network'; import { joinPath } from 'vs/base/common/resources'; import { URI } from 'vs/base/common/uri'; -import { generateUuid } from 'vs/base/common/uuid'; import { ExtensionKind, IEnvironmentService, IExtensionHostDebugParams } from 'vs/platform/environment/common/environment'; -import { IPath, IWindowConfiguration } from 'vs/platform/windows/common/windows'; +import { IPath } from 'vs/platform/windows/common/windows'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; import { IWorkbenchConstructionOptions } from 'vs/workbench/browser/web.api'; import { IProductService } from 'vs/platform/product/common/productService'; @@ -33,83 +32,10 @@ export interface IBrowserWorkbenchEnvironmentService extends IWorkbenchEnvironme readonly options?: IWorkbenchConstructionOptions; } -class BrowserWorkbenchConfiguration implements IWindowConfiguration { - - constructor( - private readonly options: IWorkbenchConstructionOptions, - private readonly payload: Map | undefined - ) { } - - @memoize - get sessionId(): string { return generateUuid(); } - - @memoize - get remoteAuthority(): string | undefined { return this.options.remoteAuthority; } - - @memoize - get filesToOpenOrCreate(): IPath[] | undefined { - if (this.payload) { - const fileToOpen = this.payload.get('openFile'); - if (fileToOpen) { - const fileUri = URI.parse(fileToOpen); - - // Support: --goto parameter to open on line/col - if (this.payload.has('gotoLineMode')) { - const pathColumnAware = parseLineAndColumnAware(fileUri.path); - - return [{ - fileUri: fileUri.with({ path: pathColumnAware.path }), - selection: !isUndefined(pathColumnAware.line) ? { startLineNumber: pathColumnAware.line, startColumn: pathColumnAware.column || 1 } : undefined - }]; - } - - return [{ fileUri }]; - } - } - - return undefined; - } - - @memoize - get filesToDiff(): IPath[] | undefined { - if (this.payload) { - const fileToDiffPrimary = this.payload.get('diffFilePrimary'); - const fileToDiffSecondary = this.payload.get('diffFileSecondary'); - if (fileToDiffPrimary && fileToDiffSecondary) { - return [ - { fileUri: URI.parse(fileToDiffSecondary) }, - { fileUri: URI.parse(fileToDiffPrimary) } - ]; - } - } - - return undefined; - } -} - -interface IExtensionHostDebugEnvironment { - params: IExtensionHostDebugParams; - debugRenderer: boolean; - isExtensionDevelopment: boolean; - extensionDevelopmentLocationURI?: URI[]; - extensionDevelopmentKind?: ExtensionKind[]; - extensionTestsLocationURI?: URI; - extensionEnabledProposedApi?: string[]; -} - export class BrowserWorkbenchEnvironmentService implements IBrowserWorkbenchEnvironmentService { declare readonly _serviceBrand: undefined; - private _configuration: IWindowConfiguration | undefined = undefined; - get configuration(): IWindowConfiguration { - if (!this._configuration) { - this._configuration = new BrowserWorkbenchConfiguration(this.options, this.payload); - } - - return this._configuration; - } - @memoize get remoteAuthority(): string | undefined { return this.options.remoteAuthority; } @@ -177,65 +103,75 @@ export class BrowserWorkbenchEnvironmentService implements IBrowserWorkbenchEnvi @memoize get extHostLogsPath(): URI { return joinPath(this.logsHome, 'exthost'); } - private _extensionHostDebugEnvironment: IExtensionHostDebugEnvironment | undefined = undefined; + private extensionHostDebugEnvironment: IExtensionHostDebugEnvironment | undefined = undefined; + + @memoize get debugExtensionHost(): IExtensionHostDebugParams { - if (!this._extensionHostDebugEnvironment) { - this._extensionHostDebugEnvironment = this.resolveExtensionHostDebugEnvironment(); + if (!this.extensionHostDebugEnvironment) { + this.extensionHostDebugEnvironment = this.resolveExtensionHostDebugEnvironment(); } - return this._extensionHostDebugEnvironment.params; + return this.extensionHostDebugEnvironment.params; } + @memoize get isExtensionDevelopment(): boolean { - if (!this._extensionHostDebugEnvironment) { - this._extensionHostDebugEnvironment = this.resolveExtensionHostDebugEnvironment(); + if (!this.extensionHostDebugEnvironment) { + this.extensionHostDebugEnvironment = this.resolveExtensionHostDebugEnvironment(); } - return this._extensionHostDebugEnvironment.isExtensionDevelopment; + return this.extensionHostDebugEnvironment.isExtensionDevelopment; } + @memoize get extensionDevelopmentLocationURI(): URI[] | undefined { - if (!this._extensionHostDebugEnvironment) { - this._extensionHostDebugEnvironment = this.resolveExtensionHostDebugEnvironment(); + if (!this.extensionHostDebugEnvironment) { + this.extensionHostDebugEnvironment = this.resolveExtensionHostDebugEnvironment(); } - return this._extensionHostDebugEnvironment.extensionDevelopmentLocationURI; + return this.extensionHostDebugEnvironment.extensionDevelopmentLocationURI; } + @memoize get extensionDevelopmentLocationKind(): ExtensionKind[] | undefined { - if (!this._extensionHostDebugEnvironment) { - this._extensionHostDebugEnvironment = this.resolveExtensionHostDebugEnvironment(); + if (!this.extensionHostDebugEnvironment) { + this.extensionHostDebugEnvironment = this.resolveExtensionHostDebugEnvironment(); } - return this._extensionHostDebugEnvironment.extensionDevelopmentKind; + return this.extensionHostDebugEnvironment.extensionDevelopmentKind; } + @memoize get extensionTestsLocationURI(): URI | undefined { - if (!this._extensionHostDebugEnvironment) { - this._extensionHostDebugEnvironment = this.resolveExtensionHostDebugEnvironment(); + if (!this.extensionHostDebugEnvironment) { + this.extensionHostDebugEnvironment = this.resolveExtensionHostDebugEnvironment(); } - return this._extensionHostDebugEnvironment.extensionTestsLocationURI; + return this.extensionHostDebugEnvironment.extensionTestsLocationURI; } + @memoize get extensionEnabledProposedApi(): string[] | undefined { - if (!this._extensionHostDebugEnvironment) { - this._extensionHostDebugEnvironment = this.resolveExtensionHostDebugEnvironment(); + if (!this.extensionHostDebugEnvironment) { + this.extensionHostDebugEnvironment = this.resolveExtensionHostDebugEnvironment(); } - return this._extensionHostDebugEnvironment.extensionEnabledProposedApi; + return this.extensionHostDebugEnvironment.extensionEnabledProposedApi; } + @memoize get debugRenderer(): boolean { - if (!this._extensionHostDebugEnvironment) { - this._extensionHostDebugEnvironment = this.resolveExtensionHostDebugEnvironment(); + if (!this.extensionHostDebugEnvironment) { + this.extensionHostDebugEnvironment = this.resolveExtensionHostDebugEnvironment(); } - return this._extensionHostDebugEnvironment.debugRenderer; + return this.extensionHostDebugEnvironment.debugRenderer; } + @memoize get disableExtensions() { return this.payload?.get('disableExtensions') === 'true'; } + @memoize get enableExtensions() { return this.options.enabledExtensions; } @memoize @@ -252,12 +188,20 @@ export class BrowserWorkbenchEnvironmentService implements IBrowserWorkbenchEnvi @memoize get telemetryLogResource(): URI { return joinPath(this.logsHome, 'telemetry.log'); } + + @memoize get disableTelemetry(): boolean { return false; } + @memoize get verbose(): boolean { return this.payload?.get('verbose') === 'true'; } + + @memoize get logExtensionHostCommunication(): boolean { return this.payload?.get('logExtensionHostCommunication') === 'true'; } + @memoize get skipReleaseNotes(): boolean { return false; } + + @memoize get skipWelcome(): boolean { return this.payload?.get('skipWelcome') === 'true'; } @memoize @@ -335,6 +279,7 @@ export class BrowserWorkbenchEnvironmentService implements IBrowserWorkbenchEnvi extensionHostDebugEnvironment.extensionDevelopmentLocationURI = developmentOptions.extensions.map(e => URI.revive(e)); extensionHostDebugEnvironment.isExtensionDevelopment = true; } + if (developmentOptions.extensionTestsPath) { extensionHostDebugEnvironment.extensionTestsLocationURI = URI.revive(developmentOptions.extensionTestsPath); } @@ -342,4 +287,54 @@ export class BrowserWorkbenchEnvironmentService implements IBrowserWorkbenchEnvi return extensionHostDebugEnvironment; } + + @memoize + get filesToOpenOrCreate(): IPath[] | undefined { + if (this.payload) { + const fileToOpen = this.payload.get('openFile'); + if (fileToOpen) { + const fileUri = URI.parse(fileToOpen); + + // Support: --goto parameter to open on line/col + if (this.payload.has('gotoLineMode')) { + const pathColumnAware = parseLineAndColumnAware(fileUri.path); + + return [{ + fileUri: fileUri.with({ path: pathColumnAware.path }), + selection: !isUndefined(pathColumnAware.line) ? { startLineNumber: pathColumnAware.line, startColumn: pathColumnAware.column || 1 } : undefined + }]; + } + + return [{ fileUri }]; + } + } + + return undefined; + } + + @memoize + get filesToDiff(): IPath[] | undefined { + if (this.payload) { + const fileToDiffPrimary = this.payload.get('diffFilePrimary'); + const fileToDiffSecondary = this.payload.get('diffFileSecondary'); + if (fileToDiffPrimary && fileToDiffSecondary) { + return [ + { fileUri: URI.parse(fileToDiffSecondary) }, + { fileUri: URI.parse(fileToDiffPrimary) } + ]; + } + } + + return undefined; + } +} + +interface IExtensionHostDebugEnvironment { + params: IExtensionHostDebugParams; + debugRenderer: boolean; + isExtensionDevelopment: boolean; + extensionDevelopmentLocationURI?: URI[]; + extensionDevelopmentKind?: ExtensionKind[]; + extensionTestsLocationURI?: URI; + extensionEnabledProposedApi?: string[]; } diff --git a/src/vs/workbench/services/environment/common/environmentService.ts b/src/vs/workbench/services/environment/common/environmentService.ts index 22d905ca964..c012e27723d 100644 --- a/src/vs/workbench/services/environment/common/environmentService.ts +++ b/src/vs/workbench/services/environment/common/environmentService.ts @@ -4,14 +4,12 @@ *--------------------------------------------------------------------------------------------*/ import { refineServiceDecorator } from 'vs/platform/instantiation/common/instantiation'; -import { IWindowConfiguration } from 'vs/platform/windows/common/windows'; +import { IPath } from 'vs/platform/windows/common/windows'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { URI } from 'vs/base/common/uri'; export const IWorkbenchEnvironmentService = refineServiceDecorator(IEnvironmentService); -export interface IWorkbenchConfiguration extends IWindowConfiguration { } - /** * A workbench specific environment service that is only present in workbench * layer. @@ -24,31 +22,27 @@ export interface IWorkbenchEnvironmentService extends IEnvironmentService { // ENVIRONMENT SERVICE // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - readonly remoteAuthority?: string; - + // --- Paths readonly logFile: URI; - readonly extHostLogsPath: URI; - readonly logExtensionHostCommunication?: boolean; + + // --- Extensions readonly extensionEnabledProposedApi?: string[]; - readonly webviewExternalEndpoint: string; - + // --- Config + readonly remoteAuthority?: string; readonly skipReleaseNotes: boolean; readonly skipWelcome: boolean; - - readonly debugRenderer: boolean; - readonly disableWorkspaceTrust: boolean; + readonly webviewExternalEndpoint: string; - /** - * @deprecated this property will go away eventually as it - * duplicates many properties of the environment service - * - * Please consider using the environment service directly - * if you can. - */ - readonly configuration: IWorkbenchConfiguration; + // --- Development + readonly debugRenderer: boolean; + readonly logExtensionHostCommunication?: boolean; + + // --- Editors to open + readonly filesToOpenOrCreate?: IPath[] | undefined + readonly filesToDiff?: IPath[] | undefined; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // NOTE: KEEP THIS INTERFACE AS SMALL AS POSSIBLE. AS SUCH: diff --git a/src/vs/workbench/services/environment/electron-sandbox/environmentService.ts b/src/vs/workbench/services/environment/electron-sandbox/environmentService.ts index a9bcfb8a68a..903f6dd7e0e 100644 --- a/src/vs/workbench/services/environment/electron-sandbox/environmentService.ts +++ b/src/vs/workbench/services/environment/electron-sandbox/environmentService.ts @@ -3,9 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { IWorkbenchConfiguration } from 'vs/workbench/services/environment/common/environmentService'; +import { PerformanceMark } from 'vs/base/common/performance'; import { IBrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService'; -import { INativeWindowConfiguration, IOSConfiguration } from 'vs/platform/windows/common/windows'; +import { IColorScheme, INativeWindowConfiguration, IOSConfiguration, IPath, IPathsToWaitFor } from 'vs/platform/windows/common/windows'; import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import { refineServiceDecorator } from 'vs/platform/instantiation/common/instantiation'; import { AbstractNativeEnvironmentService } from 'vs/platform/environment/common/environmentService'; @@ -17,37 +17,45 @@ import { IProductService } from 'vs/platform/product/common/productService'; export const INativeWorkbenchEnvironmentService = refineServiceDecorator(IEnvironmentService); -export interface INativeWorkbenchConfiguration extends IWorkbenchConfiguration, INativeWindowConfiguration { } - /** * A subclass of the `IWorkbenchEnvironmentService` to be used only in native * environments (Windows, Linux, macOS) but not e.g. web. */ export interface INativeWorkbenchEnvironmentService extends IBrowserWorkbenchEnvironmentService, INativeEnvironmentService { + // --- Window + readonly window: { + id: number; + colorScheme: IColorScheme; + maximized?: boolean; + accessibilitySupport?: boolean; + isInitialStartup?: boolean; + isCodeCaching?: boolean; + perfMarks: PerformanceMark[]; + }; + + // --- Main + readonly mainPid: number; + readonly os: IOSConfiguration; readonly machineId: string; + // --- Paths + readonly execPath: string; + readonly backupPath?: string; + + // --- Development readonly crashReporterDirectory?: string; readonly crashReporterId?: string; - readonly execPath: string; - - readonly log?: string; - - readonly os: IOSConfiguration; - - /** - * @deprecated this property will go away eventually as it - * duplicates many properties of the environment service - * - * Please consider using the environment service directly - * if you can. - */ - readonly configuration: INativeWorkbenchConfiguration; + // --- Editors to --wait + readonly filesToWait?: IPathsToWaitFor; } export class NativeWorkbenchEnvironmentService extends AbstractNativeEnvironmentService implements INativeWorkbenchEnvironmentService { + @memoize + get mainPid() { return this.configuration.mainPid; } + @memoize get machineId() { return this.configuration.machineId; } @@ -57,6 +65,22 @@ export class NativeWorkbenchEnvironmentService extends AbstractNativeEnvironment @memoize get execPath() { return this.configuration.execPath; } + @memoize + get backupPath() { return this.configuration.backupPath; } + + @memoize + get window() { + return { + id: this.configuration.windowId, + colorScheme: this.configuration.colorScheme, + maximized: this.configuration.maximized, + accessibilitySupport: this.configuration.accessibilitySupport, + perfMarks: this.configuration.perfMarks, + isInitialStartup: this.configuration.isInitialStartup, + isCodeCaching: typeof this.configuration.codeCachePath === 'string' + }; + } + @memoize override get userRoamingDataHome(): URI { return this.appSettingsHome.with({ scheme: Schemas.userData }); } @@ -91,12 +115,20 @@ export class NativeWorkbenchEnvironmentService extends AbstractNativeEnvironment return undefined; } - get os(): IOSConfiguration { - return this.configuration.os; - } + @memoize + get os(): IOSConfiguration { return this.configuration.os; } + + @memoize + get filesToOpenOrCreate(): IPath[] | undefined { return this.configuration.filesToOpenOrCreate; } + + @memoize + get filesToDiff(): IPath[] | undefined { return this.configuration.filesToDiff; } + + @memoize + get filesToWait(): IPathsToWaitFor | undefined { return this.configuration.filesToWait; } constructor( - readonly configuration: INativeWorkbenchConfiguration, + private readonly configuration: INativeWindowConfiguration, productService: IProductService ) { super(configuration, { homeDir: configuration.homeDir, tmpDir: configuration.tmpDir, userDataDir: configuration.userDataDir }, productService); diff --git a/src/vs/workbench/services/extensionManagement/test/browser/extensionEnablementService.test.ts b/src/vs/workbench/services/extensionManagement/test/browser/extensionEnablementService.test.ts index c83ccfb933b..e4927610b9c 100644 --- a/src/vs/workbench/services/extensionManagement/test/browser/extensionEnablementService.test.ts +++ b/src/vs/workbench/services/extensionManagement/test/browser/extensionEnablementService.test.ts @@ -73,7 +73,7 @@ export class TestExtensionEnablementService extends ExtensionEnablementService { storageService, new GlobalExtensionEnablementService(storageService, extensionManagementService), instantiationService.get(IWorkspaceContextService) || new TestContextService(), - instantiationService.get(IWorkbenchEnvironmentService) || instantiationService.stub(IWorkbenchEnvironmentService, { configuration: Object.create(null) } as IWorkbenchEnvironmentService), + instantiationService.get(IWorkbenchEnvironmentService) || instantiationService.stub(IWorkbenchEnvironmentService, {} as IWorkbenchEnvironmentService), workbenchExtensionManagementService, instantiationService.get(IConfigurationService), extensionManagementServerService, diff --git a/src/vs/workbench/services/extensions/electron-browser/localProcessExtensionHost.ts b/src/vs/workbench/services/extensions/electron-browser/localProcessExtensionHost.ts index 210d6947613..7145fbeab36 100644 --- a/src/vs/workbench/services/extensions/electron-browser/localProcessExtensionHost.ts +++ b/src/vs/workbench/services/extensions/electron-browser/localProcessExtensionHost.ts @@ -220,8 +220,7 @@ export class LocalProcessExtensionHost implements IExtensionHost { VSCODE_LOG_NATIVE: this._isExtensionDevHost, VSCODE_IPC_HOOK_EXTHOST: pipeName, VSCODE_HANDLES_UNCAUGHT_ERRORS: true, - VSCODE_LOG_STACK: !this._isExtensionDevTestFromCli && (this._isExtensionDevHost || !this._environmentService.isBuilt || this._productService.quality !== 'stable' || this._environmentService.verbose), - VSCODE_LOG_LEVEL: this._environmentService.verbose ? 'trace' : this._environmentService.log + VSCODE_LOG_STACK: !this._isExtensionDevTestFromCli && (this._isExtensionDevHost || !this._environmentService.isBuilt || this._productService.quality !== 'stable' || this._environmentService.verbose) }); if (this._environmentService.debugExtensionHost.env) { diff --git a/src/vs/workbench/services/host/electron-sandbox/nativeHostService.ts b/src/vs/workbench/services/host/electron-sandbox/nativeHostService.ts index 227a1887a39..81576aadd15 100644 --- a/src/vs/workbench/services/host/electron-sandbox/nativeHostService.ts +++ b/src/vs/workbench/services/host/electron-sandbox/nativeHostService.ts @@ -21,7 +21,7 @@ class WorkbenchNativeHostService extends NativeHostService { @INativeWorkbenchEnvironmentService environmentService: INativeWorkbenchEnvironmentService, @IMainProcessService mainProcessService: IMainProcessService ) { - super(environmentService.configuration.windowId, mainProcessService); + super(environmentService.window.id, mainProcessService); } } diff --git a/src/vs/workbench/services/issue/electron-sandbox/issueService.ts b/src/vs/workbench/services/issue/electron-sandbox/issueService.ts index cf004784fe9..a317690769b 100644 --- a/src/vs/workbench/services/issue/electron-sandbox/issueService.ts +++ b/src/vs/workbench/services/issue/electron-sandbox/issueService.ts @@ -97,7 +97,7 @@ export class WorkbenchIssueService implements IWorkbenchIssueService { openProcessExplorer(): Promise { const theme = this.themeService.getColorTheme(); const data: ProcessExplorerData = { - pid: this.environmentService.configuration.mainPid, + pid: this.environmentService.mainPid, zoomLevel: getZoomLevel(), styles: { backgroundColor: getColor(theme, editorBackground), diff --git a/src/vs/workbench/services/themes/electron-sandbox/nativeHostColorSchemeService.ts b/src/vs/workbench/services/themes/electron-sandbox/nativeHostColorSchemeService.ts index 4bd56248c81..a60be414226 100644 --- a/src/vs/workbench/services/themes/electron-sandbox/nativeHostColorSchemeService.ts +++ b/src/vs/workbench/services/themes/electron-sandbox/nativeHostColorSchemeService.ts @@ -35,7 +35,7 @@ export class NativeHostColorSchemeService extends Disposable implements IHostCol // register listener with the OS this._register(this.nativeHostService.onDidChangeColorScheme(scheme => this.update(scheme))); - const initial = this.getStoredValue() ?? environmentService.configuration.colorScheme; + const initial = this.getStoredValue() ?? environmentService.window.colorScheme; this.dark = initial.dark; this.highContrast = initial.highContrast; diff --git a/src/vs/workbench/services/timer/electron-sandbox/timerService.ts b/src/vs/workbench/services/timer/electron-sandbox/timerService.ts index f051292eefb..19347cb694a 100644 --- a/src/vs/workbench/services/timer/electron-sandbox/timerService.ts +++ b/src/vs/workbench/services/timer/electron-sandbox/timerService.ts @@ -38,11 +38,11 @@ export class TimerService extends AbstractTimerService { @IStorageService private readonly _storageService: IStorageService ) { super(lifecycleService, contextService, extensionService, updateService, paneCompositeService, editorService, accessibilityService, telemetryService, layoutService); - this.setPerformanceMarks('main', _environmentService.configuration.perfMarks); + this.setPerformanceMarks('main', _environmentService.window.perfMarks); } protected _isInitialStartup(): boolean { - return Boolean(this._environmentService.configuration.isInitialStartup); + return Boolean(this._environmentService.window.isInitialStartup); } protected _didUseCachedData(): boolean { return didUseCachedData(this._productService, this._storageService, this._environmentService); @@ -97,7 +97,7 @@ export function didUseCachedData(productService: IProductService, storageService // this being the first start with the commit // or subsequent if (typeof _didUseCachedData !== 'boolean') { - if (!environmentService.configuration.codeCachePath || !productService.commit) { + if (!environmentService.window.isCodeCaching || !productService.commit) { _didUseCachedData = false; // we only produce cached data whith commit and code cache path } else if (storageService.get(lastRunningCommitStorageKey, StorageScope.GLOBAL) === productService.commit) { _didUseCachedData = true; // subsequent start on same commit, assume cached data is there diff --git a/src/vs/workbench/services/workingCopy/electron-sandbox/workingCopyBackupService.ts b/src/vs/workbench/services/workingCopy/electron-sandbox/workingCopyBackupService.ts index ee86a367485..d4c07c0f67a 100644 --- a/src/vs/workbench/services/workingCopy/electron-sandbox/workingCopyBackupService.ts +++ b/src/vs/workbench/services/workingCopy/electron-sandbox/workingCopyBackupService.ts @@ -23,7 +23,7 @@ export class NativeWorkingCopyBackupService extends WorkingCopyBackupService { @ILogService logService: ILogService, @ILifecycleService private readonly lifecycleService: ILifecycleService ) { - super(environmentService.configuration.backupPath ? URI.file(environmentService.configuration.backupPath).with({ scheme: environmentService.userRoamingDataHome.scheme }) : undefined, fileService, logService); + super(environmentService.backupPath ? URI.file(environmentService.backupPath).with({ scheme: environmentService.userRoamingDataHome.scheme }) : undefined, fileService, logService); this.registerListeners(); } diff --git a/src/vs/workbench/services/workingCopy/test/electron-browser/workingCopyBackupService.test.ts b/src/vs/workbench/services/workingCopy/test/electron-browser/workingCopyBackupService.test.ts index e380d4d82c3..59ccdfb7205 100644 --- a/src/vs/workbench/services/workingCopy/test/electron-browser/workingCopyBackupService.test.ts +++ b/src/vs/workbench/services/workingCopy/test/electron-browser/workingCopyBackupService.test.ts @@ -27,7 +27,7 @@ import { IFileService } from 'vs/platform/files/common/files'; import { NativeWorkingCopyBackupService } from 'vs/workbench/services/workingCopy/electron-sandbox/workingCopyBackupService'; import { FileUserDataProvider } from 'vs/platform/userData/common/fileUserDataProvider'; import { bufferToReadable, bufferToStream, streamToBuffer, VSBuffer, VSBufferReadable, VSBufferReadableStream } from 'vs/base/common/buffer'; -import { TestWorkbenchConfiguration } from 'vs/workbench/test/electron-browser/workbenchTestServices'; +import { TestNativeWindowConfiguration } from 'vs/workbench/test/electron-browser/workbenchTestServices'; import { TestLifecycleService, TestProductService, toTypedWorkingCopyId, toUntypedWorkingCopyId } from 'vs/workbench/test/browser/workbenchTestServices'; import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation'; import { IWorkingCopyBackupMeta, IWorkingCopyIdentifier } from 'vs/workbench/services/workingCopy/common/workingCopy'; @@ -36,7 +36,7 @@ import { consumeStream } from 'vs/base/common/stream'; class TestWorkbenchEnvironmentService extends NativeWorkbenchEnvironmentService { constructor(testDir: string, backupPath: string) { - super({ ...TestWorkbenchConfiguration, backupPath, 'user-data-dir': testDir }, TestProductService); + super({ ...TestNativeWindowConfiguration, backupPath, 'user-data-dir': testDir }, TestProductService); } } diff --git a/src/vs/workbench/services/workspaces/common/workspaceTrust.ts b/src/vs/workbench/services/workspaces/common/workspaceTrust.ts index 77e979b89f9..118e5c1a0b9 100644 --- a/src/vs/workbench/services/workspaces/common/workspaceTrust.ts +++ b/src/vs/workbench/services/workspaces/common/workspaceTrust.ts @@ -215,12 +215,12 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork private async resolveCanonicalUris(): Promise { // Open editors const filesToOpen: IPath[] = []; - if (this.environmentService.configuration.filesToOpenOrCreate) { - filesToOpen.push(...this.environmentService.configuration.filesToOpenOrCreate); + if (this.environmentService.filesToOpenOrCreate) { + filesToOpen.push(...this.environmentService.filesToOpenOrCreate); } - if (this.environmentService.configuration.filesToDiff) { - filesToOpen.push(...this.environmentService.configuration.filesToDiff); + if (this.environmentService.filesToDiff) { + filesToOpen.push(...this.environmentService.filesToDiff); } if (filesToOpen.length) { diff --git a/src/vs/workbench/services/workspaces/test/common/workspaceTrust.test.ts b/src/vs/workbench/services/workspaces/test/common/workspaceTrust.test.ts index db0640b5cfa..cb8808efc50 100644 --- a/src/vs/workbench/services/workspaces/test/common/workspaceTrust.test.ts +++ b/src/vs/workbench/services/workspaces/test/common/workspaceTrust.test.ts @@ -35,7 +35,7 @@ suite('Workspace Trust', () => { configurationService = new TestConfigurationService(); instantiationService.stub(IConfigurationService, configurationService); - environmentService = { configuration: {} } as IWorkbenchEnvironmentService; + environmentService = {} as IWorkbenchEnvironmentService; instantiationService.stub(IWorkbenchEnvironmentService, environmentService); instantiationService.stub(IUriIdentityService, new UriIdentityService(new FileService(new NullLogService()))); @@ -111,7 +111,7 @@ suite('Workspace Trust', () => { const trustInfo: IWorkspaceTrustInfo = { uriTrustInfo: [{ uri: URI.parse('file:///Folder'), trusted: true }] }; storageService.store(WORKSPACE_TRUST_STORAGE_KEY, JSON.stringify(trustInfo), StorageScope.GLOBAL, StorageTarget.MACHINE); - environmentService.configuration.filesToOpenOrCreate = [{ fileUri: URI.parse('file:///Folder/file.txt') }]; + (environmentService as any).filesToOpenOrCreate = [{ fileUri: URI.parse('file:///Folder/file.txt') }]; instantiationService.stub(IWorkbenchEnvironmentService, { ...environmentService }); workspaceService.setWorkspace(new Workspace('empty-workspace')); @@ -123,7 +123,7 @@ suite('Workspace Trust', () => { test('empty workspace - trusted, open untrusted file', async () => { await configurationService.setUserConfiguration('security', getUserSettings(true, true)); - environmentService.configuration.filesToOpenOrCreate = [{ fileUri: URI.parse('file:///Folder/foo.txt') }]; + (environmentService as any).filesToOpenOrCreate = [{ fileUri: URI.parse('file:///Folder/foo.txt') }]; instantiationService.stub(IWorkbenchEnvironmentService, { ...environmentService }); workspaceService.setWorkspace(new Workspace('empty-workspace')); diff --git a/src/vs/workbench/test/electron-browser/workbenchTestServices.ts b/src/vs/workbench/test/electron-browser/workbenchTestServices.ts index 531addb02a1..33ffd4f1b50 100644 --- a/src/vs/workbench/test/electron-browser/workbenchTestServices.ts +++ b/src/vs/workbench/test/electron-browser/workbenchTestServices.ts @@ -13,7 +13,7 @@ import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/commo import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IModelService } from 'vs/editor/common/services/model'; -import { INativeWorkbenchConfiguration, INativeWorkbenchEnvironmentService, NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; +import { INativeWorkbenchEnvironmentService, NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; import { IDialogService, IFileDialogService, INativeOpenDialogOptions } from 'vs/platform/dialogs/common/dialogs'; import { ITextResourceConfigurationService } from 'vs/editor/common/services/textResourceConfiguration'; import { IProductService } from 'vs/platform/product/common/productService'; @@ -23,7 +23,7 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService import { URI } from 'vs/base/common/uri'; import { IReadTextFileOptions, ITextFileStreamContent, ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { createTextBufferFactoryFromStream } from 'vs/editor/common/model/textModel'; -import { IOpenEmptyWindowOptions, IWindowOpenable, IOpenWindowOptions, IOpenedWindow, IPartsSplash, IColorScheme } from 'vs/platform/windows/common/windows'; +import { IOpenEmptyWindowOptions, IWindowOpenable, IOpenWindowOptions, IOpenedWindow, IPartsSplash, IColorScheme, INativeWindowConfiguration } from 'vs/platform/windows/common/windows'; import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv'; import { LogLevel, ILogService } from 'vs/platform/log/common/log'; import { IPathService } from 'vs/workbench/services/path/common/pathService'; @@ -50,7 +50,7 @@ import { DisposableStore } from 'vs/base/common/lifecycle'; const args = parseArgs(process.argv, OPTIONS); -export const TestWorkbenchConfiguration: INativeWorkbenchConfiguration = { +export const TestNativeWindowConfiguration: INativeWindowConfiguration = { windowId: 0, machineId: 'testMachineId', logLevel: LogLevel.Error, @@ -68,7 +68,7 @@ export const TestWorkbenchConfiguration: INativeWorkbenchConfiguration = { ...args }; -export const TestEnvironmentService = new NativeWorkbenchEnvironmentService(TestWorkbenchConfiguration, TestProductService); +export const TestEnvironmentService = new NativeWorkbenchEnvironmentService(TestNativeWindowConfiguration, TestProductService); export class TestTextFileService extends NativeTextFileService { private resolveTextContentError!: FileOperationError | null;