Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 (#7206)

* Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463

* fix config changes

* fix strictnull checks
This commit is contained in:
Anthony Dresser
2019-09-15 22:38:26 -07:00
committed by GitHub
parent fa6c52699e
commit ea0f9e6ce9
1226 changed files with 21541 additions and 17633 deletions

View File

@@ -11,7 +11,7 @@ import * as fs from 'fs';
import * as json from 'vs/base/common/json';
import { Registry } from 'vs/platform/registry/common/platform';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { parseArgs } from 'vs/platform/environment/node/argv';
import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { TestTextFileService, workbenchInstantiationService } from 'vs/workbench/test/workbenchTestServices';
import * as uuid from 'vs/base/common/uuid';
@@ -46,7 +46,7 @@ import { FileUserDataProvider } from 'vs/workbench/services/userData/common/file
class TestEnvironmentService extends WorkbenchEnvironmentService {
constructor(private _appSettingsHome: URI) {
super(parseArgs(process.argv) as IWindowConfiguration, process.execPath);
super(parseArgs(process.argv, OPTIONS) as IWindowConfiguration, process.execPath);
}
get appSettingsHome() { return this._appSettingsHome; }
@@ -185,7 +185,7 @@ suite('ConfigurationEditingService', () => {
test('do not notify error', () => {
instantiationService.stub(ITextFileService, 'isDirty', true);
const target = sinon.stub();
instantiationService.stub(INotificationService, <INotificationService>{ prompt: target, _serviceBrand: null!, notify: null!, error: null!, info: null!, warn: null!, status: null! });
instantiationService.stub(INotificationService, <INotificationService>{ prompt: target, _serviceBrand: undefined, notify: null!, error: null!, info: null!, warn: null!, status: null! });
return testObject.writeConfiguration(EditableConfigurationTarget.USER_LOCAL, { key: 'configurationEditing.service.testSetting', value: 'value' }, { donotNotifyError: true })
.then(() => assert.fail('Should fail with ERROR_CONFIGURATION_FILE_DIRTY error.'),
(error: ConfigurationEditingError) => {

View File

@@ -11,7 +11,7 @@ import * as os from 'os';
import { URI } from 'vs/base/common/uri';
import { Registry } from 'vs/platform/registry/common/platform';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { parseArgs } from 'vs/platform/environment/node/argv';
import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv';
import * as pfs from 'vs/base/node/pfs';
import * as uuid from 'vs/base/common/uuid';
import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
@@ -51,7 +51,7 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/
class TestEnvironmentService extends WorkbenchEnvironmentService {
constructor(private _appSettingsHome: URI) {
super(parseArgs(process.argv) as IWindowConfiguration, process.execPath);
super(parseArgs(process.argv, OPTIONS) as IWindowConfiguration, process.execPath);
}
get appSettingsHome() { return this._appSettingsHome; }
@@ -735,6 +735,11 @@ suite.skip('WorkspaceConfigurationService - Folder', () => { // {{SQL CARBON EDI
'default': 'isSet',
scope: ConfigurationScope.MACHINE
},
'configurationService.folder.machineOverridableSetting': {
'type': 'string',
'default': 'isSet',
scope: ConfigurationScope.MACHINE_OVERRIDABLE
},
'configurationService.folder.testSetting': {
'type': 'string',
'default': 'isSet',
@@ -787,7 +792,7 @@ suite.skip('WorkspaceConfigurationService - Folder', () => { // {{SQL CARBON EDI
});
test('defaults', () => {
assert.deepEqual(testObject.getValue('configurationService'), { 'folder': { 'applicationSetting': 'isSet', 'machineSetting': 'isSet', 'testSetting': 'isSet' } });
assert.deepEqual(testObject.getValue('configurationService'), { 'folder': { 'applicationSetting': 'isSet', 'machineSetting': 'isSet', 'machineOverridableSetting': 'isSet', 'testSetting': 'isSet' } });
});
test('globals override defaults', () => {
@@ -815,6 +820,13 @@ suite.skip('WorkspaceConfigurationService - Folder', () => { // {{SQL CARBON EDI
.then(() => assert.equal(testObject.getValue('configurationService.folder.testSetting'), 'workspaceValue'));
});
test('machine overridable settings override user Settings', () => {
fs.writeFileSync(globalSettingsFile, '{ "configurationService.folder.machineOverridableSetting": "userValue" }');
fs.writeFileSync(path.join(workspaceDir, '.vscode', 'settings.json'), '{ "configurationService.folder.machineOverridableSetting": "workspaceValue" }');
return testObject.reloadConfiguration()
.then(() => assert.equal(testObject.getValue('configurationService.folder.machineOverridableSetting'), 'workspaceValue'));
});
test('workspace settings override user settings after defaults are registered ', () => {
fs.writeFileSync(globalSettingsFile, '{ "configurationService.folder.newSetting": "userValue" }');
fs.writeFileSync(path.join(workspaceDir, '.vscode', 'settings.json'), '{ "configurationService.folder.newSetting": "workspaceValue" }');
@@ -836,6 +848,28 @@ suite.skip('WorkspaceConfigurationService - Folder', () => { // {{SQL CARBON EDI
});
});
test('machine overridable settings override user settings after defaults are registered ', () => {
fs.writeFileSync(globalSettingsFile, '{ "configurationService.folder.newMachineOverridableSetting": "userValue" }');
fs.writeFileSync(path.join(workspaceDir, '.vscode', 'settings.json'), '{ "configurationService.folder.newMachineOverridableSetting": "workspaceValue" }');
return testObject.reloadConfiguration()
.then(() => {
configurationRegistry.registerConfiguration({
'id': '_test',
'type': 'object',
'properties': {
'configurationService.folder.newMachineOverridableSetting': {
'type': 'string',
'default': 'isSet',
scope: ConfigurationScope.MACHINE_OVERRIDABLE
}
}
});
assert.equal(testObject.getValue('configurationService.folder.newMachineOverridableSetting'), 'workspaceValue');
});
});
test('application settings are not read from workspace', () => {
fs.writeFileSync(globalSettingsFile, '{ "configurationService.folder.applicationSetting": "userValue" }');
fs.writeFileSync(path.join(workspaceDir, '.vscode', 'settings.json'), '{ "configurationService.folder.applicationSetting": "workspaceValue" }');
@@ -1066,6 +1100,11 @@ suite.skip('WorkspaceConfigurationService-Multiroot', () => { // {{SQL CARBON ED
'default': 'isSet',
scope: ConfigurationScope.MACHINE
},
'configurationService.workspace.machineOverridableSetting': {
'type': 'string',
'default': 'isSet',
scope: ConfigurationScope.MACHINE_OVERRIDABLE
},
'configurationService.workspace.testResourceSetting': {
'type': 'string',
'default': 'isSet',
@@ -1153,6 +1192,26 @@ suite.skip('WorkspaceConfigurationService-Multiroot', () => { // {{SQL CARBON ED
});
});
test('workspace settings override user settings after defaults are registered for machine overridable settings ', () => {
fs.writeFileSync(globalSettingsFile, '{ "configurationService.workspace.newMachineOverridableSetting": "userValue" }');
return jsonEditingServce.write(workspaceContextService.getWorkspace().configuration!, { key: 'settings', value: { 'configurationService.workspace.newMachineOverridableSetting': 'workspaceValue' } }, true)
.then(() => testObject.reloadConfiguration())
.then(() => {
configurationRegistry.registerConfiguration({
'id': '_test',
'type': 'object',
'properties': {
'configurationService.workspace.newMachineOverridableSetting': {
'type': 'string',
'default': 'isSet',
scope: ConfigurationScope.MACHINE_OVERRIDABLE
}
}
});
assert.equal(testObject.getValue('configurationService.workspace.newMachineOverridableSetting'), 'workspaceValue');
});
});
test('application settings are not read from workspace folder', () => {
fs.writeFileSync(globalSettingsFile, '{ "configurationService.workspace.applicationSetting": "userValue" }');
fs.writeFileSync(workspaceContextService.getWorkspace().folders[0].toResource('.vscode/settings.json').fsPath, '{ "configurationService.workspace.applicationSetting": "workspaceFolderValue" }');
@@ -1227,6 +1286,26 @@ suite.skip('WorkspaceConfigurationService-Multiroot', () => { // {{SQL CARBON ED
});
});
test('machine overridable setting in folder is read after it is registered later', () => {
fs.writeFileSync(workspaceContextService.getWorkspace().folders[0].toResource('.vscode/settings.json').fsPath, '{ "configurationService.workspace.testNewMachineOverridableSetting2": "workspaceFolderValue" }');
return jsonEditingServce.write(workspaceContextService.getWorkspace().configuration!, { key: 'settings', value: { 'configurationService.workspace.testNewMachineOverridableSetting2': 'workspaceValue' } }, true)
.then(() => testObject.reloadConfiguration())
.then(() => {
configurationRegistry.registerConfiguration({
'id': '_test',
'type': 'object',
'properties': {
'configurationService.workspace.testNewMachineOverridableSetting2': {
'type': 'string',
'default': 'isSet',
scope: ConfigurationScope.MACHINE_OVERRIDABLE
}
}
});
assert.equal(testObject.getValue('configurationService.workspace.testNewMachineOverridableSetting2', { resource: workspaceContextService.getWorkspace().folders[0].uri }), 'workspaceFolderValue');
});
});
test('inspect', () => {
let actual = testObject.inspect('something.missing');
assert.equal(actual.default, undefined);
@@ -1467,6 +1546,11 @@ suite('WorkspaceConfigurationService - Remote Folder', () => {
'default': 'isSet',
scope: ConfigurationScope.MACHINE
},
'configurationService.remote.machineOverridableSetting': {
'type': 'string',
'default': 'isSet',
scope: ConfigurationScope.MACHINE_OVERRIDABLE
},
'configurationService.remote.testSetting': {
'type': 'string',
'default': 'isSet',
@@ -1616,6 +1700,52 @@ suite('WorkspaceConfigurationService - Remote Folder', () => {
assert.equal(testObject.getValue('configurationService.remote.machineSetting'), 'isSet');
});
test('machine overridable settings in local user settings does not override defaults', async () => {
fs.writeFileSync(globalSettingsFile, '{ "configurationService.remote.machineOverridableSetting": "globalValue" }');
registerRemoteFileSystemProvider();
resolveRemoteEnvironment();
await initialize();
assert.equal(testObject.getValue('configurationService.remote.machineOverridableSetting'), 'isSet');
});
test('machine settings in local user settings does not override defaults after defalts are registered ', async () => {
fs.writeFileSync(globalSettingsFile, '{ "configurationService.remote.newMachineSetting": "userValue" }');
registerRemoteFileSystemProvider();
resolveRemoteEnvironment();
await initialize();
configurationRegistry.registerConfiguration({
'id': '_test',
'type': 'object',
'properties': {
'configurationService.remote.newMachineSetting': {
'type': 'string',
'default': 'isSet',
scope: ConfigurationScope.MACHINE
}
}
});
assert.equal(testObject.getValue('configurationService.remote.newMachineSetting'), 'isSet');
});
test('machine overridable settings in local user settings does not override defaults after defalts are registered ', async () => {
fs.writeFileSync(globalSettingsFile, '{ "configurationService.remote.newMachineOverridableSetting": "userValue" }');
registerRemoteFileSystemProvider();
resolveRemoteEnvironment();
await initialize();
configurationRegistry.registerConfiguration({
'id': '_test',
'type': 'object',
'properties': {
'configurationService.remote.newMachineOverridableSetting': {
'type': 'string',
'default': 'isSet',
scope: ConfigurationScope.MACHINE_OVERRIDABLE
}
}
});
assert.equal(testObject.getValue('configurationService.remote.newMachineOverridableSetting'), 'isSet');
});
});
function getWorkspaceId(configPath: URI): string {