mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-09 08:15:05 +01:00
introduce user roaming data home
This commit is contained in:
@@ -101,6 +101,9 @@ export interface IEnvironmentService {
|
||||
appNameLong: string;
|
||||
appQuality?: string;
|
||||
appSettingsHome: URI;
|
||||
|
||||
// user roaming data
|
||||
userRoamingDataHome: URI;
|
||||
settingsResource: URI;
|
||||
keybindingsResource: URI;
|
||||
keyboardLayoutResource: URI;
|
||||
|
||||
@@ -115,7 +115,10 @@ export class EnvironmentService implements IEnvironmentService {
|
||||
get appSettingsHome(): URI { return URI.file(path.join(this.userDataPath, 'User')); }
|
||||
|
||||
@memoize
|
||||
get settingsResource(): URI { return resources.joinPath(this.appSettingsHome, 'settings.json'); }
|
||||
get userRoamingDataHome(): URI { return this.appSettingsHome; }
|
||||
|
||||
@memoize
|
||||
get settingsResource(): URI { return resources.joinPath(this.userRoamingDataHome, 'settings.json'); }
|
||||
|
||||
@memoize
|
||||
get machineSettingsHome(): URI { return URI.file(path.join(this.userDataPath, 'Machine')); }
|
||||
@@ -136,10 +139,10 @@ export class EnvironmentService implements IEnvironmentService {
|
||||
get settingsSearchUrl(): string | undefined { return product.settingsSearchUrl; }
|
||||
|
||||
@memoize
|
||||
get keybindingsResource(): URI { return resources.joinPath(this.appSettingsHome, 'keybindings.json'); }
|
||||
get keybindingsResource(): URI { return resources.joinPath(this.userRoamingDataHome, 'keybindings.json'); }
|
||||
|
||||
@memoize
|
||||
get keyboardLayoutResource(): URI { return resources.joinPath(this.appSettingsHome, 'keyboardLayout.json'); }
|
||||
get keyboardLayoutResource(): URI { return resources.joinPath(this.userRoamingDataHome, 'keyboardLayout.json'); }
|
||||
|
||||
@memoize
|
||||
get isExtensionDevelopment(): boolean { return !!this._args.extensionDevelopmentPath; }
|
||||
|
||||
@@ -37,7 +37,7 @@ import { IWorkbenchConstructionOptions } from 'vs/workbench/workbench.web.api';
|
||||
import { ProductService } from 'vs/platform/product/browser/productService';
|
||||
import { FileUserDataProvider } from 'vs/workbench/services/userData/common/fileUserDataProvider';
|
||||
import { UserDataFileSystemProvider } from 'vs/workbench/services/userData/common/userDataFileSystemProvider';
|
||||
import { joinPath, dirname } from 'vs/base/common/resources';
|
||||
import { joinPath } from 'vs/base/common/resources';
|
||||
import { InMemoryUserDataProvider } from 'vs/workbench/services/userData/common/inMemoryUserDataProvider';
|
||||
import { IUserDataProvider } from 'vs/workbench/services/userData/common/userData';
|
||||
|
||||
@@ -91,8 +91,7 @@ class CodeRendererMain extends Disposable {
|
||||
serviceCollection.set(ILogService, logService);
|
||||
|
||||
// Environment
|
||||
const remoteUserDataUri = this.getRemoteUserDataUri();
|
||||
const environmentService = new BrowserWorkbenchEnvironmentService(this.configuration, remoteUserDataUri);
|
||||
const environmentService = new BrowserWorkbenchEnvironmentService(this.configuration);
|
||||
serviceCollection.set(IWorkbenchEnvironmentService, environmentService);
|
||||
|
||||
// Product
|
||||
@@ -124,7 +123,7 @@ class CodeRendererMain extends Disposable {
|
||||
}
|
||||
|
||||
// User Data Provider
|
||||
fileService.registerProvider(Schemas.userData, new UserDataFileSystemProvider(dirname(environmentService.settingsResource), this.getUserDataPovider(fileService, remoteUserDataUri)));
|
||||
fileService.registerProvider(Schemas.userData, new UserDataFileSystemProvider(environmentService.userRoamingDataHome, this.getUserDataPovider(fileService)));
|
||||
|
||||
const payload = await this.resolveWorkspaceInitializationPayload();
|
||||
|
||||
@@ -174,12 +173,18 @@ class CodeRendererMain extends Disposable {
|
||||
return { id: 'empty-window' };
|
||||
}
|
||||
|
||||
private getUserDataPovider(fileService: IFileService, remoteUserDataUri: URI | null): IUserDataProvider {
|
||||
private getUserDataPovider(fileService: IFileService): IUserDataProvider {
|
||||
if (this.configuration.userDataProvider) {
|
||||
return this.configuration.userDataProvider;
|
||||
} else if (this.configuration.remoteAuthority && remoteUserDataUri) {
|
||||
return this._register(new FileUserDataProvider(remoteUserDataUri, fileService));
|
||||
}
|
||||
|
||||
if (this.configuration.remoteAuthority) {
|
||||
const remoteUserDataUri = this.getRemoteUserDataUri();
|
||||
if (remoteUserDataUri) {
|
||||
return this._register(new FileUserDataProvider(remoteUserDataUri, fileService));
|
||||
}
|
||||
}
|
||||
|
||||
return this._register(new InMemoryUserDataProvider());
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,6 @@ import { SignService } from 'vs/platform/sign/node/signService';
|
||||
import { ISignService } from 'vs/platform/sign/common/sign';
|
||||
import { FileUserDataProvider } from 'vs/workbench/services/userData/common/fileUserDataProvider';
|
||||
import { UserDataFileSystemProvider } from 'vs/workbench/services/userData/common/userDataFileSystemProvider';
|
||||
import { dirname } from 'vs/base/common/resources';
|
||||
|
||||
class CodeRendererMain extends Disposable {
|
||||
|
||||
@@ -209,7 +208,7 @@ class CodeRendererMain extends Disposable {
|
||||
}
|
||||
|
||||
// User Data Provider
|
||||
fileService.registerProvider(Schemas.userData, new UserDataFileSystemProvider(dirname(environmentService.settingsResource), new FileUserDataProvider(environmentService.appSettingsHome, fileService)));
|
||||
fileService.registerProvider(Schemas.userData, new UserDataFileSystemProvider(environmentService.userRoamingDataHome, new FileUserDataProvider(environmentService.appSettingsHome, fileService)));
|
||||
|
||||
const payload = await this.resolveWorkspaceInitializationPayload(environmentService);
|
||||
|
||||
|
||||
+3
-13
@@ -10,7 +10,7 @@ import * as path from 'vs/base/common/path';
|
||||
import * as fs from 'fs';
|
||||
import * as json from 'vs/base/common/json';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { ParsedArgs, IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { parseArgs } from 'vs/platform/environment/node/argv';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { TestTextFileService, workbenchInstantiationService } from 'vs/workbench/test/workbenchTestServices';
|
||||
@@ -38,22 +38,12 @@ import { Schemas } from 'vs/base/common/network';
|
||||
import { DiskFileSystemProvider } from 'vs/workbench/services/files/node/diskFileSystemProvider';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { ConfigurationCache } from 'vs/workbench/services/configuration/node/configurationCache';
|
||||
import { dirname } from 'vs/base/common/resources';
|
||||
import { KeybindingsEditingService, IKeybindingEditingService } from 'vs/workbench/services/keybinding/common/keybindingEditing';
|
||||
import { UserDataFileSystemProvider } from 'vs/workbench/services/userData/common/userDataFileSystemProvider';
|
||||
import { WorkbenchEnvironmentService } from 'vs/workbench/services/environment/node/environmentService';
|
||||
import { IWindowConfiguration } from 'vs/platform/windows/common/windows';
|
||||
import { FileUserDataProvider } from 'vs/workbench/services/userData/common/fileUserDataProvider';
|
||||
|
||||
class SettingsTestEnvironmentService extends WorkbenchEnvironmentService {
|
||||
|
||||
constructor(args: ParsedArgs, _execPath: string, private _settingsPath: string) {
|
||||
super(<IWindowConfiguration>args, _execPath);
|
||||
}
|
||||
|
||||
get appSettingsHome(): URI { return dirname(URI.file(this._settingsPath)); }
|
||||
}
|
||||
|
||||
suite('ConfigurationEditingService', () => {
|
||||
|
||||
let instantiationService: TestInstantiationService;
|
||||
@@ -105,14 +95,14 @@ suite('ConfigurationEditingService', () => {
|
||||
clearServices();
|
||||
|
||||
instantiationService = <TestInstantiationService>workbenchInstantiationService();
|
||||
const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile);
|
||||
const environmentService = new WorkbenchEnvironmentService(<IWindowConfiguration>parseArgs(process.argv), process.execPath);
|
||||
instantiationService.stub(IEnvironmentService, environmentService);
|
||||
const remoteAgentService = instantiationService.createInstance(RemoteAgentService, {});
|
||||
const fileService = new FileService(new NullLogService());
|
||||
fileService.registerProvider(Schemas.file, new DiskFileSystemProvider(new NullLogService()));
|
||||
instantiationService.stub(IFileService, fileService);
|
||||
instantiationService.stub(IRemoteAgentService, remoteAgentService);
|
||||
fileService.registerProvider(Schemas.userData, new UserDataFileSystemProvider(environmentService.appSettingsHome.with({ scheme: Schemas.userData }), new FileUserDataProvider(environmentService.appSettingsHome, fileService)));
|
||||
fileService.registerProvider(Schemas.userData, new UserDataFileSystemProvider(URI.file('/User').with({ scheme: Schemas.userData }), new FileUserDataProvider(URI.file(workspaceDir), fileService)));
|
||||
const workspaceService = new WorkspaceService({ configurationCache: new ConfigurationCache(environmentService) }, environmentService, fileService, remoteAgentService);
|
||||
instantiationService.stub(IWorkspaceContextService, workspaceService);
|
||||
return workspaceService.initialize(noWorkspace ? { id: '' } : { folder: URI.file(workspaceDir), id: createHash('md5').update(URI.file(workspaceDir).toString()).digest('hex') }).then(() => {
|
||||
|
||||
+17
-27
@@ -10,7 +10,7 @@ import * as path from 'vs/base/common/path';
|
||||
import * as os from 'os';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { ParsedArgs, IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { parseArgs } from 'vs/platform/environment/node/argv';
|
||||
import * as pfs from 'vs/base/node/pfs';
|
||||
import * as uuid from 'vs/base/common/uuid';
|
||||
@@ -30,7 +30,7 @@ import { IJSONEditingService } from 'vs/workbench/services/configuration/common/
|
||||
import { JSONEditingService } from 'vs/workbench/services/configuration/common/jsonEditingService';
|
||||
import { createHash } from 'crypto';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { originalFSPath, dirname } from 'vs/base/common/resources';
|
||||
import { originalFSPath } from 'vs/base/common/resources';
|
||||
import { isLinux } from 'vs/base/common/platform';
|
||||
import { IWindowConfiguration } from 'vs/platform/windows/common/windows';
|
||||
import { RemoteAgentService } from 'vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl';
|
||||
@@ -50,15 +50,6 @@ import { WorkbenchEnvironmentService } from 'vs/workbench/services/environment/n
|
||||
import { UserDataFileSystemProvider } from 'vs/workbench/services/userData/common/userDataFileSystemProvider';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
|
||||
class SettingsTestEnvironmentService extends WorkbenchEnvironmentService {
|
||||
|
||||
constructor(args: ParsedArgs, _execPath: string, private _settingsPath: string) {
|
||||
super(<IWindowConfiguration>args, _execPath);
|
||||
}
|
||||
|
||||
get appSettingsHome(): URI { return dirname(URI.file(this._settingsPath)); }
|
||||
}
|
||||
|
||||
function setUpFolderWorkspace(folderName: string): Promise<{ parentDir: string, folderDir: string }> {
|
||||
const id = uuid.generateUuid();
|
||||
const parentDir = path.join(os.tmpdir(), 'vsctests', id);
|
||||
@@ -105,10 +96,9 @@ suite('WorkspaceContextService - Folder', () => {
|
||||
.then(({ parentDir, folderDir }) => {
|
||||
parentResource = parentDir;
|
||||
workspaceResource = folderDir;
|
||||
const globalSettingsFile = path.join(parentDir, 'settings.json');
|
||||
const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile);
|
||||
const environmentService = new WorkbenchEnvironmentService(<IWindowConfiguration>parseArgs(process.argv), process.execPath);
|
||||
const fileService = new FileService(new NullLogService());
|
||||
fileService.registerProvider(Schemas.userData, new UserDataFileSystemProvider(environmentService.appSettingsHome.with({ scheme: Schemas.userData }), new FileUserDataProvider(environmentService.appSettingsHome, fileService)));
|
||||
fileService.registerProvider(Schemas.userData, new UserDataFileSystemProvider(URI.file('/User').with({ scheme: Schemas.userData }), new FileUserDataProvider(URI.file(parentDir), fileService)));
|
||||
workspaceContextService = new WorkspaceService({ configurationCache: new ConfigurationCache(environmentService) }, environmentService, fileService, new RemoteAgentService(<IWindowConfiguration>{}, environmentService, new RemoteAuthorityResolverService(), new SignService()));
|
||||
return (<WorkspaceService>workspaceContextService).initialize(convertToWorkspacePayload(URI.file(folderDir)));
|
||||
});
|
||||
@@ -168,12 +158,12 @@ suite('WorkspaceContextService - Workspace', () => {
|
||||
parentResource = parentDir;
|
||||
|
||||
instantiationService = <TestInstantiationService>workbenchInstantiationService();
|
||||
const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, path.join(parentDir, 'settings.json'));
|
||||
const environmentService = new WorkbenchEnvironmentService(<IWindowConfiguration>parseArgs(process.argv), process.execPath);
|
||||
const remoteAgentService = instantiationService.createInstance(RemoteAgentService, {});
|
||||
instantiationService.stub(IRemoteAgentService, remoteAgentService);
|
||||
const fileService = new FileService(new NullLogService());
|
||||
fileService.registerProvider(Schemas.file, new DiskFileSystemProvider(new NullLogService()));
|
||||
fileService.registerProvider(Schemas.userData, new UserDataFileSystemProvider(environmentService.appSettingsHome.with({ scheme: Schemas.userData }), new FileUserDataProvider(environmentService.appSettingsHome, fileService)));
|
||||
fileService.registerProvider(Schemas.userData, new UserDataFileSystemProvider(URI.file('/User').with({ scheme: Schemas.userData }), new FileUserDataProvider(URI.file(parentDir), fileService)));
|
||||
const workspaceService = new WorkspaceService({ configurationCache: new ConfigurationCache(environmentService) }, environmentService, fileService, remoteAgentService);
|
||||
|
||||
instantiationService.stub(IWorkspaceContextService, workspaceService);
|
||||
@@ -227,12 +217,12 @@ suite('WorkspaceContextService - Workspace Editing', () => {
|
||||
parentResource = parentDir;
|
||||
|
||||
instantiationService = <TestInstantiationService>workbenchInstantiationService();
|
||||
const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, path.join(parentDir, 'settings.json'));
|
||||
const environmentService = new WorkbenchEnvironmentService(<IWindowConfiguration>parseArgs(process.argv), process.execPath);
|
||||
const remoteAgentService = instantiationService.createInstance(RemoteAgentService, {});
|
||||
instantiationService.stub(IRemoteAgentService, remoteAgentService);
|
||||
const fileService = new FileService(new NullLogService());
|
||||
fileService.registerProvider(Schemas.file, new DiskFileSystemProvider(new NullLogService()));
|
||||
fileService.registerProvider(Schemas.userData, new UserDataFileSystemProvider(environmentService.appSettingsHome.with({ scheme: Schemas.userData }), new FileUserDataProvider(environmentService.appSettingsHome, fileService)));
|
||||
fileService.registerProvider(Schemas.userData, new UserDataFileSystemProvider(URI.file('/User').with({ scheme: Schemas.userData }), new FileUserDataProvider(URI.file(parentDir), fileService)));
|
||||
const workspaceService = new WorkspaceService({ configurationCache: new ConfigurationCache(environmentService) }, environmentService, fileService, remoteAgentService);
|
||||
|
||||
instantiationService.stub(IWorkspaceContextService, workspaceService);
|
||||
@@ -487,12 +477,12 @@ suite('WorkspaceService - Initialization', () => {
|
||||
globalSettingsFile = path.join(parentDir, 'settings.json');
|
||||
|
||||
const instantiationService = <TestInstantiationService>workbenchInstantiationService();
|
||||
const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile);
|
||||
const environmentService = new WorkbenchEnvironmentService(<IWindowConfiguration>parseArgs(process.argv), process.execPath);
|
||||
const remoteAgentService = instantiationService.createInstance(RemoteAgentService, {});
|
||||
instantiationService.stub(IRemoteAgentService, remoteAgentService);
|
||||
const fileService = new FileService(new NullLogService());
|
||||
fileService.registerProvider(Schemas.file, new DiskFileSystemProvider(new NullLogService()));
|
||||
fileService.registerProvider(Schemas.userData, new UserDataFileSystemProvider(environmentService.appSettingsHome.with({ scheme: Schemas.userData }), new FileUserDataProvider(environmentService.appSettingsHome, fileService)));
|
||||
fileService.registerProvider(Schemas.userData, new UserDataFileSystemProvider(URI.file('/User').with({ scheme: Schemas.userData }), new FileUserDataProvider(URI.file(parentDir), fileService)));
|
||||
const workspaceService = new WorkspaceService({ configurationCache: new ConfigurationCache(environmentService) }, environmentService, fileService, remoteAgentService);
|
||||
instantiationService.stub(IWorkspaceContextService, workspaceService);
|
||||
instantiationService.stub(IConfigurationService, workspaceService);
|
||||
@@ -750,12 +740,12 @@ suite('WorkspaceConfigurationService - Folder', () => {
|
||||
globalSettingsFile = path.join(parentDir, 'settings.json');
|
||||
|
||||
const instantiationService = <TestInstantiationService>workbenchInstantiationService();
|
||||
const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile);
|
||||
const environmentService = new WorkbenchEnvironmentService(<IWindowConfiguration>parseArgs(process.argv), process.execPath);
|
||||
const remoteAgentService = instantiationService.createInstance(RemoteAgentService, {});
|
||||
instantiationService.stub(IRemoteAgentService, remoteAgentService);
|
||||
const fileService = new FileService(new NullLogService());
|
||||
fileService.registerProvider(Schemas.file, new DiskFileSystemProvider(new NullLogService()));
|
||||
fileService.registerProvider(Schemas.userData, new UserDataFileSystemProvider(environmentService.appSettingsHome.with({ scheme: Schemas.userData }), new FileUserDataProvider(environmentService.appSettingsHome, fileService)));
|
||||
fileService.registerProvider(Schemas.userData, new UserDataFileSystemProvider(URI.file('/User').with({ scheme: Schemas.userData }), new FileUserDataProvider(URI.file(parentDir), fileService)));
|
||||
const workspaceService = new WorkspaceService({ configurationCache: new ConfigurationCache(environmentService) }, environmentService, fileService, remoteAgentService);
|
||||
instantiationService.stub(IWorkspaceContextService, workspaceService);
|
||||
instantiationService.stub(IConfigurationService, workspaceService);
|
||||
@@ -1040,7 +1030,7 @@ suite('WorkspaceConfigurationService - Folder', () => {
|
||||
|
||||
suite('WorkspaceConfigurationService-Multiroot', () => {
|
||||
|
||||
let parentResource: string, workspaceContextService: IWorkspaceContextService, environmentService: IWorkbenchEnvironmentService, jsonEditingServce: IJSONEditingService, testObject: IConfigurationService, globalSettingsFile: string;
|
||||
let parentResource: string, workspaceContextService: IWorkspaceContextService, jsonEditingServce: IJSONEditingService, testObject: IConfigurationService, globalSettingsFile: string;
|
||||
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
|
||||
|
||||
suiteSetup(() => {
|
||||
@@ -1079,12 +1069,12 @@ suite('WorkspaceConfigurationService-Multiroot', () => {
|
||||
globalSettingsFile = path.join(parentDir, 'settings.json');
|
||||
|
||||
const instantiationService = <TestInstantiationService>workbenchInstantiationService();
|
||||
environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile);
|
||||
const environmentService = new WorkbenchEnvironmentService(<IWindowConfiguration>parseArgs(process.argv), process.execPath);
|
||||
const remoteAgentService = instantiationService.createInstance(RemoteAgentService, {});
|
||||
instantiationService.stub(IRemoteAgentService, remoteAgentService);
|
||||
const fileService = new FileService(new NullLogService());
|
||||
fileService.registerProvider(Schemas.file, new DiskFileSystemProvider(new NullLogService()));
|
||||
fileService.registerProvider(Schemas.userData, new UserDataFileSystemProvider(environmentService.appSettingsHome.with({ scheme: Schemas.userData }), new FileUserDataProvider(environmentService.appSettingsHome, fileService)));
|
||||
fileService.registerProvider(Schemas.userData, new UserDataFileSystemProvider(URI.file('/User').with({ scheme: Schemas.userData }), new FileUserDataProvider(URI.file(parentDir), fileService)));
|
||||
const workspaceService = new WorkspaceService({ configurationCache: new ConfigurationCache(environmentService) }, environmentService, fileService, remoteAgentService);
|
||||
|
||||
instantiationService.stub(IWorkspaceContextService, workspaceService);
|
||||
@@ -1481,12 +1471,12 @@ suite('WorkspaceConfigurationService - Remote Folder', () => {
|
||||
remoteSettingsFile = path.join(parentDir, 'remote-settings.json');
|
||||
|
||||
instantiationService = <TestInstantiationService>workbenchInstantiationService();
|
||||
const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile);
|
||||
const environmentService = new WorkbenchEnvironmentService(<IWindowConfiguration>parseArgs(process.argv), process.execPath);
|
||||
const remoteEnvironmentPromise = new Promise<Partial<IRemoteAgentEnvironment>>(c => resolveRemoteEnvironment = () => c({ settingsPath: URI.file(remoteSettingsFile).with({ scheme: Schemas.vscodeRemote, authority: remoteAuthority }) }));
|
||||
const remoteAgentService = instantiationService.stub(IRemoteAgentService, <Partial<IRemoteAgentService>>{ getEnvironment: () => remoteEnvironmentPromise });
|
||||
const fileService = new FileService(new NullLogService());
|
||||
fileService.registerProvider(Schemas.file, diskFileSystemProvider);
|
||||
fileService.registerProvider(Schemas.userData, new UserDataFileSystemProvider(environmentService.appSettingsHome.with({ scheme: Schemas.userData }), new FileUserDataProvider(environmentService.appSettingsHome, fileService)));
|
||||
fileService.registerProvider(Schemas.userData, new UserDataFileSystemProvider(URI.file('/User').with({ scheme: Schemas.userData }), new FileUserDataProvider(URI.file(parentDir), fileService)));
|
||||
const configurationCache: IConfigurationCache = { read: () => Promise.resolve(''), write: () => Promise.resolve(), remove: () => Promise.resolve() };
|
||||
testObject = new WorkspaceService({ configurationCache, remoteAuthority }, environmentService, fileService, remoteAgentService);
|
||||
instantiationService.stub(IWorkspaceContextService, testObject);
|
||||
|
||||
@@ -63,24 +63,16 @@ export class BrowserWorkbenchEnvironmentService implements IEnvironmentService {
|
||||
|
||||
readonly configuration: IWindowConfiguration = new BrowserWindowConfiguration();
|
||||
|
||||
constructor(configuration: IWorkbenchConstructionOptions, remoteUserDataUri: URI | null) {
|
||||
constructor(configuration: IWorkbenchConstructionOptions) {
|
||||
this.args = { _: [] };
|
||||
this.appRoot = '/web/';
|
||||
this.appNameLong = 'Visual Studio Code - Web';
|
||||
|
||||
this.configuration.remoteAuthority = configuration.remoteAuthority;
|
||||
|
||||
if (remoteUserDataUri) {
|
||||
this.appSettingsHome = remoteUserDataUri;
|
||||
this.settingsResource = joinPath(this.appSettingsHome, 'settings.json').with({ scheme: Schemas.userData });
|
||||
this.keybindingsResource = joinPath(this.appSettingsHome, 'keybindings.json').with({ scheme: Schemas.userData });
|
||||
} else {
|
||||
const appSettingsHome = URI.file('/User').with({ scheme: Schemas.userData });
|
||||
this.settingsResource = joinPath(appSettingsHome, 'settings.json');
|
||||
this.keybindingsResource = joinPath(appSettingsHome, 'keybindings.json');
|
||||
}
|
||||
|
||||
this.keyboardLayoutResource = joinPath(this.appSettingsHome, 'keyboardLayout.json');
|
||||
this.userRoamingDataHome = URI.file('/User').with({ scheme: Schemas.userData });
|
||||
this.settingsResource = joinPath(this.userRoamingDataHome, 'settings.json');
|
||||
this.keybindingsResource = joinPath(this.userRoamingDataHome, 'keybindings.json');
|
||||
this.keyboardLayoutResource = joinPath(this.userRoamingDataHome, 'keyboardLayout.json');
|
||||
|
||||
this.logsPath = '/web/logs';
|
||||
|
||||
@@ -104,6 +96,7 @@ export class BrowserWorkbenchEnvironmentService implements IEnvironmentService {
|
||||
appNameLong: string;
|
||||
appQuality?: string;
|
||||
appSettingsHome: URI;
|
||||
userRoamingDataHome: URI;
|
||||
settingsResource: URI;
|
||||
keybindingsResource: URI;
|
||||
keyboardLayoutResource: URI;
|
||||
|
||||
@@ -8,7 +8,6 @@ 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';
|
||||
import { joinPath } from 'vs/base/common/resources';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
|
||||
export class WorkbenchEnvironmentService extends EnvironmentService implements IWorkbenchEnvironmentService {
|
||||
@@ -27,8 +26,5 @@ export class WorkbenchEnvironmentService extends EnvironmentService implements I
|
||||
}
|
||||
|
||||
@memoize
|
||||
get settingsResource(): URI { return joinPath(this.appSettingsHome, 'settings.json').with({ scheme: Schemas.userData }); }
|
||||
|
||||
@memoize
|
||||
get keybindingsResource(): URI { return joinPath(this.appSettingsHome, 'keybindings.json').with({ scheme: Schemas.userData }); }
|
||||
get userRoamingDataHome(): URI { return this.appSettingsHome.with({ scheme: Schemas.userData }); }
|
||||
}
|
||||
|
||||
+4
-13
@@ -21,7 +21,7 @@ import { ITextResourcePropertiesService } from 'vs/editor/common/services/resour
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ConfigurationService } from 'vs/platform/configuration/node/configurationService';
|
||||
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { IUserFriendlyKeybinding } from 'vs/platform/keybinding/common/keybinding';
|
||||
@@ -47,10 +47,9 @@ import { DiskFileSystemProvider } from 'vs/workbench/services/files/node/diskFil
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { UserDataFileSystemProvider } from 'vs/workbench/services/userData/common/userDataFileSystemProvider';
|
||||
import { FileUserDataProvider } from 'vs/workbench/services/userData/common/fileUserDataProvider';
|
||||
import { parseArgs } from 'vs/platform/environment/node/argv';
|
||||
import { WorkbenchEnvironmentService } from 'vs/workbench/services/environment/node/environmentService';
|
||||
import { IWindowConfiguration } from 'vs/platform/windows/common/windows';
|
||||
import { parseArgs } from 'vs/platform/environment/node/argv';
|
||||
import { dirname } from 'vs/base/common/resources';
|
||||
|
||||
interface Modifiers {
|
||||
metaKey?: boolean;
|
||||
@@ -59,14 +58,6 @@ interface Modifiers {
|
||||
shiftKey?: boolean;
|
||||
}
|
||||
|
||||
class SettingsTestEnvironmentService extends WorkbenchEnvironmentService {
|
||||
constructor(args: ParsedArgs, _execPath: string, private _appSettingsHome: URI) {
|
||||
super(<IWindowConfiguration>args, _execPath);
|
||||
}
|
||||
|
||||
get appSettingsHome(): URI { return this._appSettingsHome; }
|
||||
}
|
||||
|
||||
suite('KeybindingsEditing', () => {
|
||||
|
||||
let instantiationService: TestInstantiationService;
|
||||
@@ -80,7 +71,7 @@ suite('KeybindingsEditing', () => {
|
||||
|
||||
instantiationService = new TestInstantiationService();
|
||||
|
||||
const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, URI.file(testDir));
|
||||
const environmentService = new WorkbenchEnvironmentService(<IWindowConfiguration>parseArgs(process.argv), process.execPath);
|
||||
instantiationService.stub(IEnvironmentService, environmentService);
|
||||
instantiationService.stub(IConfigurationService, ConfigurationService);
|
||||
instantiationService.stub(IConfigurationService, 'getValue', { 'eol': '\n' });
|
||||
@@ -99,7 +90,7 @@ suite('KeybindingsEditing', () => {
|
||||
instantiationService.stub(IModelService, instantiationService.createInstance(ModelServiceImpl));
|
||||
const fileService = new FileService(new NullLogService());
|
||||
fileService.registerProvider(Schemas.file, new DiskFileSystemProvider(new NullLogService()));
|
||||
fileService.registerProvider(Schemas.userData, new UserDataFileSystemProvider(dirname(environmentService.keybindingsResource), new FileUserDataProvider(environmentService.appSettingsHome, fileService)));
|
||||
fileService.registerProvider(Schemas.userData, new UserDataFileSystemProvider(URI.file('/User').with({ scheme: Schemas.userData }), new FileUserDataProvider(URI.file(testDir), fileService)));
|
||||
instantiationService.stub(IFileService, fileService);
|
||||
instantiationService.stub(IUntitledEditorService, instantiationService.createInstance(UntitledEditorService));
|
||||
instantiationService.stub(ITextFileService, instantiationService.createInstance(TestTextFileService));
|
||||
|
||||
@@ -390,7 +390,7 @@ export class EncodingOracle extends Disposable implements IResourceEncodings {
|
||||
const defaultEncodingOverrides: IEncodingOverride[] = [];
|
||||
|
||||
// Global settings
|
||||
defaultEncodingOverrides.push({ parent: this.environmentService.appSettingsHome, encoding: UTF8 });
|
||||
defaultEncodingOverrides.push({ parent: this.environmentService.userRoamingDataHome, encoding: UTF8 });
|
||||
|
||||
// Workspace files
|
||||
defaultEncodingOverrides.push({ extension: WORKSPACE_EXTENSION, encoding: UTF8 });
|
||||
|
||||
Reference in New Issue
Block a user