debt - move native pieces of window config into node layer

This commit is contained in:
Benjamin Pasero
2020-03-02 12:35:20 +01:00
parent cf4b29104b
commit 9eedabce7b
24 changed files with 160 additions and 191 deletions
+1 -1
View File
@@ -31,7 +31,7 @@ exports.load = function (modulePaths, resultCallback, options) {
const args = parseURLQueryArgs();
/**
* // configuration: IWindowConfiguration
* // configuration: INativeWindowConfiguration
* @type {{
* zoomLevel?: number,
* extensionDevelopmentPath?: string[],
+1 -1
View File
@@ -175,7 +175,7 @@ function configureCommandlineSwitchesSync(cliArgs) {
app.commandLine.appendSwitch('js-flags', jsFlags);
}
// TODO@Ben TODO@Deepak Electron 7 workaround for https://github.com/microsoft/vscode/issues/88873
// TODO@Deepak Electron 7 workaround for https://github.com/microsoft/vscode/issues/88873
app.commandLine.appendSwitch('disable-features', 'LayoutNG');
return argvConfig;
-3
View File
@@ -239,10 +239,7 @@ suite('Glob', () => {
assertGlobMatch(p, 'some/folder/project.json');
assertNoGlobMatch(p, 'some/folder/file_project.json');
assertNoGlobMatch(p, 'some/folder/fileproject.json');
// assertNoGlobMatch(p, '/rrproject.json'); TODO@ben this still fails if T1-3 are disabled
assertNoGlobMatch(p, 'some/rrproject.json');
// assertNoGlobMatch(p, 'rrproject.json');
// assertNoGlobMatch(p, '\\rrproject.json');
assertNoGlobMatch(p, 'some\\rrproject.json');
p = 'test/**';
@@ -39,7 +39,7 @@ import { ITelemetryServiceConfig, TelemetryService } from 'vs/platform/telemetry
import { combinedAppender, LogAppender, NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
import { resolveCommonProperties } from 'vs/platform/telemetry/node/commonProperties';
import { TelemetryAppenderClient } from 'vs/platform/telemetry/node/telemetryIpc';
import { IWindowConfiguration } from 'vs/platform/windows/common/windows';
import { INativeWindowConfiguration } from 'vs/platform/windows/node/window';
const MAX_URL_LENGTH = 2045;
@@ -49,7 +49,7 @@ interface SearchResult {
state?: string;
}
export interface IssueReporterConfiguration extends IWindowConfiguration {
export interface IssueReporterConfiguration extends INativeWindowConfiguration {
data: IssueReporterData;
features: IssueReporterFeatures;
}
@@ -316,7 +316,7 @@ export class IssueReporter extends Disposable {
}
}
private initServices(configuration: IWindowConfiguration): void {
private initServices(configuration: INativeWindowConfiguration): void {
const serviceCollection = new ServiceCollection();
const mainProcessService = new MainProcessService(configuration.windowId);
serviceCollection.set(IMainProcessService, mainProcessService);
+1 -1
View File
@@ -133,7 +133,7 @@ export class CodeApplication extends Disposable {
//
// !!! DO NOT CHANGE without consulting the documentation !!!
//
// app.on('remote-get-guest-web-contents', event => event.preventDefault()); // TODO@Ben TODO@Matt revisit this need for <webview>
// app.on('remote-get-guest-web-contents', event => event.preventDefault()); // TODO@Matt revisit this need for <webview>
app.on('remote-require', (event, sender, module) => {
this.logService.trace('App#on(remote-require): prevented');
+8 -7
View File
@@ -14,10 +14,11 @@ import { ILogService } from 'vs/platform/log/common/log';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv';
import product from 'vs/platform/product/common/product';
import { IWindowSettings, MenuBarVisibility, IWindowConfiguration, ReadyState, getTitleBarStyle, getMenuBarVisibility } from 'vs/platform/windows/common/windows';
import { IWindowSettings, MenuBarVisibility, ReadyState, getTitleBarStyle, getMenuBarVisibility } from 'vs/platform/windows/common/windows';
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
import { isLinux, isMacintosh, isWindows } from 'vs/base/common/platform';
import { ICodeWindow, IWindowState, WindowMode } from 'vs/platform/windows/electron-main/windows';
import { INativeWindowConfiguration } from 'vs/platform/windows/node/window';
import { IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { IWorkspacesMainService } from 'vs/platform/workspaces/electron-main/workspacesMainService';
import { IBackupMainService } from 'vs/platform/backup/electron-main/backup';
@@ -85,7 +86,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
private readonly whenReadyCallbacks: { (window: ICodeWindow): void }[];
private pendingLoadConfig?: IWindowConfiguration;
private pendingLoadConfig?: INativeWindowConfiguration;
private marketplaceHeadersPromise: Promise<object>;
@@ -231,8 +232,8 @@ export class CodeWindow extends Disposable implements ICodeWindow {
this.registerListeners();
}
private currentConfig: IWindowConfiguration | undefined;
get config(): IWindowConfiguration | undefined { return this.currentConfig; }
private currentConfig: INativeWindowConfiguration | undefined;
get config(): INativeWindowConfiguration | undefined { return this.currentConfig; }
private _id: number;
get id(): number { return this._id; }
@@ -552,7 +553,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
}
}
load(config: IWindowConfiguration, isReload?: boolean, disableExtensions?: boolean): void {
load(config: INativeWindowConfiguration, isReload?: boolean, disableExtensions?: boolean): void {
// If this is the first time the window is loaded, we associate the paths
// directly with the window because we assume the loading will just work
@@ -612,7 +613,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
this._onLoad.fire();
}
reload(configurationIn?: IWindowConfiguration, cli?: ParsedArgs): void {
reload(configurationIn?: INativeWindowConfiguration, cli?: ParsedArgs): void {
// If config is not provided, copy our current one
const configuration = configurationIn ? configurationIn : objects.mixin({}, this.currentConfig);
@@ -639,7 +640,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
this.load(configuration, true, disableExtensions);
}
private getUrl(windowConfiguration: IWindowConfiguration): string {
private getUrl(windowConfiguration: INativeWindowConfiguration): string {
// Set window ID
windowConfiguration.windowId = this._win.id;
+1 -27
View File
@@ -3,11 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IProcessEnvironment, isMacintosh, isLinux, isWeb } from 'vs/base/common/platform';
import { isMacintosh, isLinux, isWeb } from 'vs/base/common/platform';
import { ParsedArgs, IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { ExportData } from 'vs/base/common/performance';
import { LogLevel } from 'vs/platform/log/common/log';
import { URI, UriComponents } from 'vs/base/common/uri';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
@@ -220,41 +218,17 @@ export interface IAddFoldersRequest {
}
export interface IWindowConfiguration extends ParsedArgs {
machineId?: string; // NOTE: This is undefined in the web, the telemetry service directly resolves this.
windowId: number; // TODO: should we deprecate this in favor of sessionId?
sessionId: string;
logLevel: LogLevel;
mainPid: number;
appRoot: string;
execPath: string;
isInitialStartup?: boolean;
userEnv: IProcessEnvironment;
nodeCachedDataDir?: string;
backupPath?: string;
backupWorkspaceResource?: URI;
workspace?: IWorkspaceIdentifier;
folderUri?: ISingleFolderWorkspaceIdentifier;
remoteAuthority?: string;
connectionToken?: string;
zoomLevel?: number;
fullscreen?: boolean;
maximized?: boolean;
highContrast?: boolean;
accessibilitySupport?: boolean;
partsSplashPath?: string;
perfEntries: ExportData;
filesToOpenOrCreate?: IPath[];
filesToDiff?: IPath[];
filesToWait?: IPathsToWaitFor;
}
export interface IRunActionInWindowRequest {
@@ -3,7 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { OpenContext, IWindowConfiguration, IWindowOpenable, IOpenEmptyWindowOptions } from 'vs/platform/windows/common/windows';
import { OpenContext, IWindowOpenable, IOpenEmptyWindowOptions } from 'vs/platform/windows/common/windows';
import { INativeWindowConfiguration } from 'vs/platform/windows/node/window';
import { ParsedArgs } from 'vs/platform/environment/common/environment';
import { Event } from 'vs/base/common/event';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
@@ -39,7 +40,7 @@ export interface ICodeWindow extends IDisposable {
readonly id: number;
readonly win: BrowserWindow;
readonly config: IWindowConfiguration | undefined;
readonly config: INativeWindowConfiguration | undefined;
readonly openedFolderUri?: URI;
readonly openedWorkspace?: IWorkspaceIdentifier;
@@ -60,8 +61,8 @@ export interface ICodeWindow extends IDisposable {
addTabbedWindow(window: ICodeWindow): void;
load(config: IWindowConfiguration, isReload?: boolean): void;
reload(configuration?: IWindowConfiguration, cli?: ParsedArgs): void;
load(config: INativeWindowConfiguration, isReload?: boolean): void;
reload(configuration?: INativeWindowConfiguration, cli?: ParsedArgs): void;
focus(): void;
close(): void;
@@ -18,8 +18,8 @@ import { parseLineAndColumnAware } from 'vs/code/node/paths';
import { ILifecycleMainService, UnloadReason, LifecycleMainService, LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ILogService } from 'vs/platform/log/common/log';
import { IWindowSettings, OpenContext, IPath, IWindowConfiguration, IPathsToWaitFor, isFileToOpen, isWorkspaceToOpen, isFolderToOpen, IWindowOpenable, IOpenEmptyWindowOptions, IAddFoldersRequest } from 'vs/platform/windows/common/windows';
import { getLastActiveWindow, findBestWindowOrFolderForFile, findWindowOnWorkspace, findWindowOnExtensionDevelopmentPath, findWindowOnWorkspaceOrFolderUri } from 'vs/platform/windows/node/window';
import { IWindowSettings, OpenContext, IPath, IPathsToWaitFor, isFileToOpen, isWorkspaceToOpen, isFolderToOpen, IWindowOpenable, IOpenEmptyWindowOptions, IAddFoldersRequest } from 'vs/platform/windows/common/windows';
import { getLastActiveWindow, findBestWindowOrFolderForFile, findWindowOnWorkspace, findWindowOnExtensionDevelopmentPath, findWindowOnWorkspaceOrFolderUri, INativeWindowConfiguration } from 'vs/platform/windows/node/window';
import { Emitter } from 'vs/base/common/event';
import product from 'vs/platform/product/common/product';
import { IWindowsMainService, IOpenConfiguration, IWindowsCountChangedEvent, ICodeWindow, IWindowState as ISingleWindowState, WindowMode } from 'vs/platform/windows/electron-main/windows';
@@ -1354,8 +1354,8 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
private openInBrowserWindow(options: IOpenBrowserWindowOptions): ICodeWindow {
// Build IWindowConfiguration from config and options
const configuration: IWindowConfiguration = mixin({}, options.cli); // inherit all properties from CLI
// Build INativeWindowConfiguration from config and options
const configuration: INativeWindowConfiguration = mixin({}, options.cli); // inherit all properties from CLI
configuration.appRoot = this.environmentService.appRoot;
configuration.machineId = this.machineId;
configuration.nodeCachedDataDir = this.environmentService.nodeCachedDataDir;
@@ -1482,7 +1482,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
return window;
}
private doOpenInBrowserWindow(window: ICodeWindow, configuration: IWindowConfiguration, options: IOpenBrowserWindowOptions): void {
private doOpenInBrowserWindow(window: ICodeWindow, configuration: INativeWindowConfiguration, options: IOpenBrowserWindowOptions): void {
// Register window for backups
if (!configuration.extensionDevelopmentPath) {
@@ -1500,7 +1500,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
window.load(configuration);
}
private getNewWindowState(configuration: IWindowConfiguration): INewWindowState {
private getNewWindowState(configuration: INativeWindowConfiguration): INewWindowState {
const lastActive = this.getLastActiveWindow();
// Restore state unless we are running extension tests
+31 -1
View File
@@ -3,12 +3,42 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { OpenContext, IOpenWindowOptions } from 'vs/platform/windows/common/windows';
import { OpenContext, IOpenWindowOptions, IWindowConfiguration, IPathsToWaitFor } from 'vs/platform/windows/common/windows';
import { URI } from 'vs/base/common/uri';
import * as platform from 'vs/base/common/platform';
import * as extpath from 'vs/base/common/extpath';
import { IWorkspaceIdentifier, IResolvedWorkspace, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { isEqual, isEqualOrParent } from 'vs/base/common/resources';
import { LogLevel } from 'vs/platform/log/common/log';
import { ExportData } from 'vs/base/common/performance';
export interface INativeWindowConfiguration extends IWindowConfiguration {
mainPid: number;
windowId: number;
machineId: string; // NOTE: This is undefined in the web, the telemetry service directly resolves this.
appRoot: string;
execPath: string;
backupPath?: string;
nodeCachedDataDir?: string;
partsSplashPath: string;
workspace?: IWorkspaceIdentifier;
folderUri?: ISingleFolderWorkspaceIdentifier;
isInitialStartup?: boolean;
logLevel: LogLevel;
zoomLevel?: number;
fullscreen?: boolean;
maximized?: boolean;
accessibilitySupport?: boolean;
perfEntries: ExportData;
userEnv: platform.IProcessEnvironment;
filesToWait?: IPathsToWaitFor;
}
export interface INativeOpenWindowOptions extends IOpenWindowOptions {
diffMode?: boolean;
@@ -14,6 +14,7 @@ import { assign } from 'vs/base/common/objects';
import { IWorkbenchIssueService } from 'vs/workbench/contrib/issue/electron-browser/issue';
import { ExtensionType } from 'vs/platform/extensions/common/extensions';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
export class WorkbenchIssueService implements IWorkbenchIssueService {
_serviceBrand: undefined;
@@ -23,7 +24,7 @@ export class WorkbenchIssueService implements IWorkbenchIssueService {
@IThemeService private readonly themeService: IThemeService,
@IExtensionManagementService private readonly extensionManagementService: IExtensionManagementService,
@IWorkbenchExtensionEnablementService private readonly extensionEnablementService: IWorkbenchExtensionEnablementService,
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService
@IWorkbenchEnvironmentService private readonly environmentService: INativeWorkbenchEnvironmentService
) { }
openReporter(dataOverrides: Partial<IssueReporterData> = {}): Promise<void> {
@@ -38,6 +38,7 @@ import { IHostService } from 'vs/workbench/services/host/browser/host';
import { RemoteConnectionState, Deprecated_RemoteAuthorityContext, RemoteFileDialogContext } from 'vs/workbench/browser/contextkeys';
import { IDownloadService } from 'vs/platform/download/common/download';
import { OpenLocalFileFolderCommand, OpenLocalFileCommand, OpenLocalFolderCommand, SaveLocalFileCommand } from 'vs/workbench/services/dialogs/browser/simpleFileDialog';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
const WINDOW_ACTIONS_COMMAND_ID = 'workbench.action.remote.showMenu';
const CLOSE_REMOTE_COMMAND_ID = 'workbench.action.remote.close';
@@ -331,7 +332,7 @@ class RemoteTelemetryEnablementUpdater extends Disposable implements IWorkbenchC
class RemoteEmptyWorkbenchPresentation extends Disposable implements IWorkbenchContribution {
constructor(
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
@IWorkbenchEnvironmentService environmentService: INativeWorkbenchEnvironmentService,
@IRemoteAuthorityResolverService remoteAuthorityResolverService: IRemoteAuthorityResolverService,
@IConfigurationService configurationService: IConfigurationService,
@ICommandService commandService: ICommandService,
@@ -6,6 +6,7 @@
import * as fs from 'fs';
import * as gracefulFs from 'graceful-fs';
import { createHash } from 'crypto';
import { webFrame } from 'electron';
import { importEntries, mark } from 'vs/base/common/performance';
import { Workbench } from 'vs/workbench/browser/workbench';
import { ElectronWindow } from 'vs/workbench/electron-browser/window';
@@ -20,8 +21,7 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { stat } from 'vs/base/node/pfs';
import { KeyboardMapperFactory } from 'vs/workbench/services/keybinding/electron-browser/nativeKeymapService';
import { IWindowConfiguration } from 'vs/platform/windows/common/windows';
import { webFrame } from 'electron';
import { INativeWindowConfiguration } from 'vs/platform/windows/node/window';
import { ISingleFolderWorkspaceIdentifier, IWorkspaceInitializationPayload, ISingleFolderWorkspaceInitializationPayload, reviveWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { ConsoleLogService, MultiplexLogService, ILogService, ConsoleLogInMainService } from 'vs/platform/log/common/log';
import { NativeStorageService } from 'vs/platform/storage/node/storageService';
@@ -57,7 +57,7 @@ class DesktopMain extends Disposable {
private readonly environmentService: NativeWorkbenchEnvironmentService;
constructor(private configuration: IWindowConfiguration) {
constructor(private configuration: INativeWindowConfiguration) {
super();
this.environmentService = new NativeWorkbenchEnvironmentService(configuration, configuration.execPath, configuration.windowId);
@@ -373,7 +373,7 @@ class DesktopMain extends Disposable {
}
}
export function main(configuration: IWindowConfiguration): Promise<void> {
export function main(configuration: INativeWindowConfiguration): Promise<void> {
const renderer = new DesktopMain(configuration);
return renderer.open();
+2 -1
View File
@@ -62,6 +62,7 @@ import { IElectronEnvironmentService } from 'vs/workbench/services/electron/elec
import { IWorkingCopyService, WorkingCopyCapabilities } from 'vs/workbench/services/workingCopy/common/workingCopyService';
import { AutoSaveMode, IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
import { Event } from 'vs/base/common/event';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
export class ElectronWindow extends Disposable {
@@ -94,7 +95,7 @@ export class ElectronWindow extends Disposable {
@IMenuService private readonly menuService: IMenuService,
@ILifecycleService private readonly lifecycleService: ILifecycleService,
@IIntegrityService private readonly integrityService: IIntegrityService,
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
@IWorkbenchEnvironmentService private readonly environmentService: INativeWorkbenchEnvironmentService,
@IAccessibilityService private readonly accessibilityService: IAccessibilityService,
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@@ -16,6 +16,7 @@ import { IJSONEditingService } from 'vs/workbench/services/configuration/common/
import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
interface AccessibilityMetrics {
enabled: boolean;
@@ -24,14 +25,14 @@ type AccessibilityMetricsClassification = {
enabled: { classification: 'SystemMetaData', purpose: 'FeatureInsight' };
};
export class NodeAccessibilityService extends AccessibilityService implements IAccessibilityService {
export class NativeAccessibilityService extends AccessibilityService implements IAccessibilityService {
_serviceBrand: undefined;
private didSendTelemetry = false;
constructor(
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
@IWorkbenchEnvironmentService environmentService: INativeWorkbenchEnvironmentService,
@IContextKeyService contextKeyService: IContextKeyService,
@IConfigurationService configurationService: IConfigurationService,
@ITelemetryService private readonly _telemetryService: ITelemetryService
@@ -69,7 +70,7 @@ export class NodeAccessibilityService extends AccessibilityService implements IA
}
}
registerSingleton(IAccessibilityService, NodeAccessibilityService, true);
registerSingleton(IAccessibilityService, NativeAccessibilityService, true);
// On linux we do not automatically detect that a screen reader is detected, thus we have to implicitly notify the renderer to enable accessibility when user configures it in settings
class LinuxAccessibilityContribution implements IWorkbenchContribution {
@@ -340,7 +340,7 @@ export class ConfigurationResolverService extends BaseConfigurationResolverServi
@IWorkspaceContextService workspaceContextService: IWorkspaceContextService,
@IQuickInputService quickInputService: IQuickInputService
) {
super(environmentService.configuration.userEnv, editorService, environmentService, configurationService, commandService, workspaceContextService, quickInputService);
super(Object.create(null), editorService, environmentService, configurationService, commandService, workspaceContextService, quickInputService);
}
}
@@ -9,7 +9,7 @@ import * as platform from 'vs/base/common/platform';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver';
import { ConfigurationResolverService } from 'vs/workbench/services/configurationResolver/browser/configurationResolverService';
import { BaseConfigurationResolverService } from 'vs/workbench/services/configurationResolver/browser/configurationResolverService';
import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { TestEditorService, TestContextService } from 'vs/workbench/test/browser/workbenchTestServices';
import { TestWindowConfiguration } from 'vs/workbench/test/electron-browser/workbenchTestServices';
@@ -21,7 +21,6 @@ import * as Types from 'vs/base/common/types';
import { EditorType } from 'vs/editor/common/editorCommon';
import { Selection } from 'vs/editor/common/core/selection';
import { NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
const mockLineNumber = 10;
class TestEditorServiceWithActiveEditor extends TestEditorService {
@@ -37,10 +36,14 @@ class TestEditorServiceWithActiveEditor extends TestEditorService {
}
}
class TestConfigurationResolverService extends BaseConfigurationResolverService {
}
suite('Configuration Resolver Service', () => {
let configurationResolverService: IConfigurationResolverService | null;
let envVariables: { [key: string]: string } = { key1: 'Value for key1', key2: 'Value for key2' };
let environmentService: IWorkbenchEnvironmentService;
let environmentService: MockWorkbenchEnvironmentService;
let mockCommandService: MockCommandService;
let editorService: TestEditorServiceWithActiveEditor;
let workspace: IWorkspaceFolder;
@@ -57,7 +60,7 @@ suite('Configuration Resolver Service', () => {
index: 0,
toResource: (path: string) => uri.file(path)
};
configurationResolverService = new ConfigurationResolverService(editorService, environmentService, new MockInputsConfigurationService(), mockCommandService, new TestContextService(), quickInputService);
configurationResolverService = new TestConfigurationResolverService(environmentService.userEnv, editorService, environmentService, new MockInputsConfigurationService(), mockCommandService, new TestContextService(), quickInputService);
});
teardown(() => {
@@ -136,7 +139,7 @@ suite('Configuration Resolver Service', () => {
}
});
let service = new ConfigurationResolverService(new TestEditorServiceWithActiveEditor(), environmentService, configurationService, mockCommandService, new TestContextService(), quickInputService);
let service = new TestConfigurationResolverService(environmentService.userEnv, new TestEditorServiceWithActiveEditor(), environmentService, configurationService, mockCommandService, new TestContextService(), quickInputService);
assert.strictEqual(service.resolve(workspace, 'abc ${config:editor.fontFamily} xyz'), 'abc foo xyz');
});
@@ -153,7 +156,7 @@ suite('Configuration Resolver Service', () => {
}
});
let service = new ConfigurationResolverService(new TestEditorServiceWithActiveEditor(), environmentService, configurationService, mockCommandService, new TestContextService(), quickInputService);
let service = new TestConfigurationResolverService(environmentService.userEnv, new TestEditorServiceWithActiveEditor(), environmentService, configurationService, mockCommandService, new TestContextService(), quickInputService);
assert.strictEqual(service.resolve(workspace, 'abc ${config:editor.fontFamily} ${config:terminal.integrated.fontFamily} xyz'), 'abc foo bar xyz');
});
@@ -170,7 +173,7 @@ suite('Configuration Resolver Service', () => {
}
});
let service = new ConfigurationResolverService(new TestEditorServiceWithActiveEditor(), environmentService, configurationService, mockCommandService, new TestContextService(), quickInputService);
let service = new TestConfigurationResolverService(environmentService.userEnv, new TestEditorServiceWithActiveEditor(), environmentService, configurationService, mockCommandService, new TestContextService(), quickInputService);
if (platform.isWindows) {
assert.strictEqual(service.resolve(workspace, 'abc ${config:editor.fontFamily} ${workspaceFolder} ${env:key1} xyz'), 'abc foo \\VSCode\\workspaceLocation Value for key1 xyz');
} else {
@@ -191,7 +194,7 @@ suite('Configuration Resolver Service', () => {
}
});
let service = new ConfigurationResolverService(new TestEditorServiceWithActiveEditor(), environmentService, configurationService, mockCommandService, new TestContextService(), quickInputService);
let service = new TestConfigurationResolverService(environmentService.userEnv, new TestEditorServiceWithActiveEditor(), environmentService, configurationService, mockCommandService, new TestContextService(), quickInputService);
if (platform.isWindows) {
assert.strictEqual(service.resolve(workspace, '${config:editor.fontFamily} ${config:terminal.integrated.fontFamily} ${workspaceFolder} - ${workspaceFolder} ${env:key1} - ${env:key2}'), 'foo bar \\VSCode\\workspaceLocation - \\VSCode\\workspaceLocation Value for key1 - Value for key2');
} else {
@@ -225,7 +228,7 @@ suite('Configuration Resolver Service', () => {
}
});
let service = new ConfigurationResolverService(new TestEditorServiceWithActiveEditor(), environmentService, configurationService, mockCommandService, new TestContextService(), quickInputService);
let service = new TestConfigurationResolverService(environmentService.userEnv, new TestEditorServiceWithActiveEditor(), environmentService, configurationService, mockCommandService, new TestContextService(), quickInputService);
assert.strictEqual(service.resolve(workspace, 'abc ${config:editor.fontFamily} ${config:editor.lineNumbers} ${config:editor.insertSpaces} xyz'), 'abc foo 123 false xyz');
});
@@ -235,7 +238,7 @@ suite('Configuration Resolver Service', () => {
editor: {}
});
let service = new ConfigurationResolverService(new TestEditorServiceWithActiveEditor(), environmentService, configurationService, mockCommandService, new TestContextService(), quickInputService);
let service = new TestConfigurationResolverService(environmentService.userEnv, new TestEditorServiceWithActiveEditor(), environmentService, configurationService, mockCommandService, new TestContextService(), quickInputService);
assert.strictEqual(service.resolve(workspace, 'abc ${unknownVariable} xyz'), 'abc ${unknownVariable} xyz');
assert.strictEqual(service.resolve(workspace, 'abc ${env:unknownVariable} xyz'), 'abc xyz');
});
@@ -248,7 +251,7 @@ suite('Configuration Resolver Service', () => {
}
});
let service = new ConfigurationResolverService(new TestEditorServiceWithActiveEditor(), environmentService, configurationService, mockCommandService, new TestContextService(), quickInputService);
let service = new TestConfigurationResolverService(environmentService.userEnv, new TestEditorServiceWithActiveEditor(), environmentService, configurationService, mockCommandService, new TestContextService(), quickInputService);
assert.throws(() => service.resolve(workspace, 'abc ${env} xyz'));
assert.throws(() => service.resolve(workspace, 'abc ${env:} xyz'));
@@ -619,7 +622,7 @@ class MockInputsConfigurationService extends TestConfigurationService {
class MockWorkbenchEnvironmentService extends NativeWorkbenchEnvironmentService {
constructor(userEnv: platform.IProcessEnvironment) {
constructor(public userEnv: platform.IProcessEnvironment) {
super({ ...TestWindowConfiguration, userEnv }, TestWindowConfiguration.execPath, TestWindowConfiguration.windowId);
}
}
@@ -4,22 +4,17 @@
*--------------------------------------------------------------------------------------------*/
import { Schemas } from 'vs/base/common/network';
import { ExportData } from 'vs/base/common/performance';
import { IProcessEnvironment } from 'vs/base/common/platform';
import { joinPath } from 'vs/base/common/resources';
import { URI } from 'vs/base/common/uri';
import { generateUuid } from 'vs/base/common/uuid';
import { BACKUPS, IExtensionHostDebugParams } from 'vs/platform/environment/common/environment';
import { LogLevel } from 'vs/platform/log/common/log';
import { IPath, IPathsToWaitFor, IWindowConfiguration } from 'vs/platform/windows/common/windows';
import { ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { IPath, IWindowConfiguration } from 'vs/platform/windows/common/windows';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IWorkbenchConstructionOptions } from 'vs/workbench/workbench.web.api';
import product from 'vs/platform/product/common/product';
import { serializableToMap } from 'vs/base/common/map';
import { memoize } from 'vs/base/common/decorators';
// TODO@ben remove properties that are node/electron only
export class BrowserWindowConfiguration implements IWindowConfiguration {
constructor(
@@ -28,8 +23,6 @@ export class BrowserWindowConfiguration implements IWindowConfiguration {
private readonly environment: IWorkbenchEnvironmentService
) { }
//#region PROPERLY CONFIGURED IN DESKTOP + WEB
@memoize
get sessionId(): string { return generateUuid(); }
@@ -54,44 +47,10 @@ export class BrowserWindowConfiguration implements IWindowConfiguration {
return undefined;
}
// Currently unsupported in web
// Currently unsupported in web but should look into support
get filesToDiff(): IPath[] | undefined { return undefined; }
//#endregion
//#region TODO MOVE TO NODE LAYER
_!: string[];
windowId!: number;
mainPid!: number;
logLevel!: LogLevel;
appRoot!: string;
execPath!: string;
backupPath?: string;
nodeCachedDataDir?: string;
userEnv!: IProcessEnvironment;
workspace?: IWorkspaceIdentifier;
folderUri?: ISingleFolderWorkspaceIdentifier;
zoomLevel?: number;
fullscreen?: boolean;
maximized?: boolean;
highContrast?: boolean;
accessibilitySupport?: boolean;
partsSplashPath?: string;
isInitialStartup?: boolean;
perfEntries!: ExportData;
filesToWait?: IPathsToWaitFor;
//#endregion
highContrast = false;
_ = [];
private getCookieValue(name: string): string | undefined {
const m = document.cookie.match('(^|[^;]+)\\s*' + name + '\\s*=\\s*([^;]+)'); // See https://stackoverflow.com/a/25490531
@@ -116,7 +75,14 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment
_serviceBrand: undefined;
//#region PROPERLY CONFIGURED IN DESKTOP + WEB
private _configuration: IWindowConfiguration | undefined = undefined;
get configuration(): IWindowConfiguration {
if (!this._configuration) {
this._configuration = new BrowserWindowConfiguration(this.options, this.payload, this);
}
return this._configuration;
}
@memoize
get isBuilt(): boolean { return !!product.commit; }
@@ -209,71 +175,14 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment
return this.webviewExternalEndpoint.replace('{{uuid}}', '*');
}
// Currently not configurable in web
// Currently unsupported in web but should look into support
get disableExtensions() { return false; }
get extensionsPath(): string | undefined { return undefined; }
get verbose(): boolean { return false; }
get disableUpdates(): boolean { return false; }
get logExtensionHostCommunication(): boolean { return false; }
//#endregion
//#region TODO MOVE TO NODE LAYER
private _configuration: IWindowConfiguration | undefined = undefined;
get configuration(): IWindowConfiguration {
if (!this._configuration) {
this._configuration = new BrowserWindowConfiguration(this.options, this.payload, this);
}
return this._configuration;
}
args = { _: [] };
wait!: boolean;
status!: boolean;
log?: string;
mainIPCHandle!: string;
sharedIPCHandle!: string;
nodeCachedDataDir?: string;
disableCrashReporter!: boolean;
driverHandle?: string;
driverVerbose!: boolean;
installSourcePath!: string;
builtinExtensionsPath!: string;
globalStorageHome!: string;
workspaceStorageHome!: string;
backupWorkspacesPath!: string;
machineSettingsHome!: URI;
machineSettingsResource!: URI;
userHome!: string;
userDataPath!: string;
appRoot!: string;
appSettingsHome!: URI;
execPath!: string;
cliPath!: string;
//#endregion
//#region TODO ENABLE IN WEB
galleryMachineIdResource?: URI;
//#endregion
private payload: Map<string, string> | undefined;
constructor(readonly options: IBrowserWorkbenchEnvironmentConstructionOptions) {
@@ -316,4 +225,43 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment
return extensionHostDebugEnvironment;
}
//#region TODO MOVE TO NODE LAYER
args = { _: [] };
wait!: boolean;
status!: boolean;
log?: string;
mainIPCHandle!: string;
sharedIPCHandle!: string;
nodeCachedDataDir?: string;
disableCrashReporter!: boolean;
driverHandle?: string;
driverVerbose!: boolean;
installSourcePath!: string;
builtinExtensionsPath!: string;
globalStorageHome!: string;
workspaceStorageHome!: string;
backupWorkspacesPath!: string;
machineSettingsHome!: URI;
machineSettingsResource!: URI;
userHome!: string;
userDataPath!: string;
appRoot!: string;
appSettingsHome!: URI;
execPath!: string;
cliPath!: string;
//#endregion
}
@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
import { IWindowConfiguration } from 'vs/platform/windows/common/windows';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { memoize } from 'vs/base/common/decorators';
import { URI } from 'vs/base/common/uri';
@@ -12,8 +11,14 @@ import { Schemas } from 'vs/base/common/network';
import { toBackupWorkspaceResource } from 'vs/workbench/services/backup/electron-browser/backup';
import { join } from 'vs/base/common/path';
import product from 'vs/platform/product/common/product';
import { INativeWindowConfiguration } from 'vs/platform/windows/node/window';
export class NativeWorkbenchEnvironmentService extends EnvironmentService implements IWorkbenchEnvironmentService {
export interface INativeWorkbenchEnvironmentService extends IWorkbenchEnvironmentService {
readonly configuration: INativeWindowConfiguration;
}
export class NativeWorkbenchEnvironmentService extends EnvironmentService implements INativeWorkbenchEnvironmentService {
_serviceBrand: undefined;
@@ -37,7 +42,7 @@ export class NativeWorkbenchEnvironmentService extends EnvironmentService implem
get logFile(): URI { return URI.file(join(this.logsPath, `renderer${this.windowId}.log`)); }
constructor(
readonly configuration: IWindowConfiguration,
readonly configuration: INativeWindowConfiguration,
execPath: string,
private readonly windowId: number
) {
@@ -17,6 +17,7 @@ import { resolveWorkbenchCommonProperties } from 'vs/platform/telemetry/node/wor
import { TelemetryService as BaseTelemetryService, ITelemetryServiceConfig } from 'vs/platform/telemetry/common/telemetryService';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { ClassifiedEvent, StrictPropertyCheck, GDPRClassification } from 'vs/platform/telemetry/common/gdprTypings';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
export class TelemetryService extends Disposable implements ITelemetryService {
@@ -25,7 +26,7 @@ export class TelemetryService extends Disposable implements ITelemetryService {
private impl: ITelemetryService;
constructor(
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
@IWorkbenchEnvironmentService environmentService: INativeWorkbenchEnvironmentService,
@IProductService productService: IProductService,
@ISharedProcessService sharedProcessService: ISharedProcessService,
@ILogService logService: ILogService,
@@ -38,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.configuration.remoteAuthority),
commonProperties: resolveWorkbenchCommonProperties(storageService, productService.commit, productService.version, environmentService.configuration.machineId, productService.msftInternalDomains, environmentService.installSourcePath, environmentService.configuration.remoteAuthority),
piiPaths: environmentService.extensionsPath ? [environmentService.appRoot, environmentService.extensionsPath] : [environmentService.appRoot]
};
@@ -18,6 +18,7 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
/* __GDPR__FRAGMENT__
"IMemoryInfo" : {
@@ -303,7 +304,7 @@ class TimerService implements ITimerService {
constructor(
@IElectronService private readonly _electronService: IElectronService,
@IWorkbenchEnvironmentService private readonly _environmentService: IWorkbenchEnvironmentService,
@IWorkbenchEnvironmentService private readonly _environmentService: INativeWorkbenchEnvironmentService,
@ILifecycleService private readonly _lifecycleService: ILifecycleService,
@IWorkspaceContextService private readonly _contextService: IWorkspaceContextService,
@IExtensionService private readonly _extensionService: IExtensionService,
@@ -31,6 +31,7 @@ import { IElectronService } from 'vs/platform/electron/node/electron';
import { isMacintosh } from 'vs/base/common/platform';
import { mnemonicButtonLabel } from 'vs/base/common/labels';
import { BackupFileService } from 'vs/workbench/services/backup/common/backupFileService';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
export class NativeWorkspaceEditingService extends AbstractWorkspaceEditingService {
@@ -49,7 +50,7 @@ export class NativeWorkspaceEditingService extends AbstractWorkspaceEditingServi
@IFileService fileService: IFileService,
@ITextFileService textFileService: ITextFileService,
@IWorkspacesService workspacesService: IWorkspacesService,
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
@IWorkbenchEnvironmentService protected environmentService: INativeWorkbenchEnvironmentService,
@IFileDialogService fileDialogService: IFileDialogService,
@IDialogService protected dialogService: IDialogService,
@ILifecycleService private readonly lifecycleService: ILifecycleService,
@@ -25,7 +25,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 { IOpenedWindow, IOpenEmptyWindowOptions, IWindowOpenable, IOpenWindowOptions, IWindowConfiguration } from 'vs/platform/windows/common/windows';
import { IOpenedWindow, IOpenEmptyWindowOptions, IWindowOpenable, IOpenWindowOptions } from 'vs/platform/windows/common/windows';
import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv';
import { LogLevel } from 'vs/platform/log/common/log';
import { IRemotePathService } from 'vs/workbench/services/path/common/remotePathService';
@@ -37,12 +37,15 @@ import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
import { NodeTestBackupFileService } from 'vs/workbench/services/backup/test/electron-browser/backupFileService.test';
import { IWorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { INativeWindowConfiguration } from 'vs/platform/windows/node/window';
export const TestWindowConfiguration: IWindowConfiguration = {
export const TestWindowConfiguration: INativeWindowConfiguration = {
windowId: 0,
machineId: 'testMachineId',
sessionId: 'testSessionId',
logLevel: LogLevel.Error,
mainPid: 0,
partsSplashPath: '',
appRoot: '',
userEnv: {},
execPath: process.execPath,
+1 -1
View File
@@ -43,7 +43,7 @@ import 'vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl';
import 'vs/workbench/services/telemetry/electron-browser/telemetryService';
import 'vs/workbench/services/configurationResolver/electron-browser/configurationResolverService';
import 'vs/workbench/services/extensionManagement/node/extensionManagementService';
import 'vs/workbench/services/accessibility/node/accessibilityService';
import 'vs/workbench/services/accessibility/electron-browser/accessibilityService';
import 'vs/workbench/services/remote/node/tunnelService';
import 'vs/workbench/services/backup/node/backupFileService';
import 'vs/workbench/services/url/electron-browser/urlService';