mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge from vscode cbeff45f80213db0ddda2183170281ed97ed3b12 (#8670)
* Merge from vscode cbeff45f80213db0ddda2183170281ed97ed3b12 * fix null strict checks
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import { merge, removeFromValueTree } from 'vs/platform/configuration/common/configuration';
|
||||
import { mergeChanges } from 'vs/platform/configuration/common/configurationModels';
|
||||
|
||||
suite('Configuration', () => {
|
||||
|
||||
@@ -104,4 +105,43 @@ suite('Configuration', () => {
|
||||
assert.deepEqual(target, { 'a': { 'b': { 'd': 1 } } });
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
suite('Configuration Changes: Merge', () => {
|
||||
|
||||
test('merge only keys', () => {
|
||||
const actual = mergeChanges({ keys: ['a', 'b'], overrides: [] }, { keys: ['c', 'd'], overrides: [] });
|
||||
assert.deepEqual(actual, { keys: ['a', 'b', 'c', 'd'], overrides: [] });
|
||||
});
|
||||
|
||||
test('merge only keys with duplicates', () => {
|
||||
const actual = mergeChanges({ keys: ['a', 'b'], overrides: [] }, { keys: ['c', 'd'], overrides: [] }, { keys: ['a', 'd', 'e'], overrides: [] });
|
||||
assert.deepEqual(actual, { keys: ['a', 'b', 'c', 'd', 'e'], overrides: [] });
|
||||
});
|
||||
|
||||
test('merge only overrides', () => {
|
||||
const actual = mergeChanges({ keys: [], overrides: [['a', ['1', '2']]] }, { keys: [], overrides: [['b', ['3', '4']]] });
|
||||
assert.deepEqual(actual, { keys: [], overrides: [['a', ['1', '2']], ['b', ['3', '4']]] });
|
||||
});
|
||||
|
||||
test('merge only overrides with duplicates', () => {
|
||||
const actual = mergeChanges({ keys: [], overrides: [['a', ['1', '2']], ['b', ['5', '4']]] }, { keys: [], overrides: [['b', ['3', '4']]] }, { keys: [], overrides: [['c', ['1', '4']], ['a', ['2', '3']]] });
|
||||
assert.deepEqual(actual, { keys: [], overrides: [['a', ['1', '2', '3']], ['b', ['5', '4', '3']], ['c', ['1', '4']]] });
|
||||
});
|
||||
|
||||
test('merge', () => {
|
||||
const actual = mergeChanges({ keys: ['b', 'b'], overrides: [['a', ['1', '2']], ['b', ['5', '4']]] }, { keys: ['b'], overrides: [['b', ['3', '4']]] }, { keys: ['c', 'a'], overrides: [['c', ['1', '4']], ['a', ['2', '3']]] });
|
||||
assert.deepEqual(actual, { keys: ['b', 'c', 'a'], overrides: [['a', ['1', '2', '3']], ['b', ['5', '4', '3']], ['c', ['1', '4']]] });
|
||||
});
|
||||
|
||||
test('merge single change', () => {
|
||||
const actual = mergeChanges({ keys: ['b', 'b'], overrides: [['a', ['1', '2']], ['b', ['5', '4']]] });
|
||||
assert.deepEqual(actual, { keys: ['b', 'b'], overrides: [['a', ['1', '2']], ['b', ['5', '4']]] });
|
||||
});
|
||||
|
||||
test('merge no changes', () => {
|
||||
const actual = mergeChanges();
|
||||
assert.deepEqual(actual, { keys: [], overrides: [] });
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -3,10 +3,13 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import { ConfigurationModel, DefaultConfigurationModel, ConfigurationChangeEvent, ConfigurationModelParser, Configuration } from 'vs/platform/configuration/common/configurationModels';
|
||||
import { ConfigurationModel, DefaultConfigurationModel, ConfigurationChangeEvent, ConfigurationModelParser, Configuration, mergeChanges, AllKeysConfigurationChangeEvent } from 'vs/platform/configuration/common/configurationModels';
|
||||
import { Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Workspace, WorkspaceFolder } from 'vs/platform/workspace/common/workspace';
|
||||
import { join } from 'vs/base/common/path';
|
||||
import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
|
||||
|
||||
suite('ConfigurationModel', () => {
|
||||
|
||||
@@ -103,7 +106,7 @@ suite('ConfigurationModel', () => {
|
||||
test('get overriding configuration model for an existing identifier', () => {
|
||||
let testObject = new ConfigurationModel(
|
||||
{ 'a': { 'b': 1 }, 'f': 1 }, [],
|
||||
[{ identifiers: ['c'], contents: { 'a': { 'd': 1 } } }]);
|
||||
[{ identifiers: ['c'], contents: { 'a': { 'd': 1 } }, keys: ['a'] }]);
|
||||
|
||||
assert.deepEqual(testObject.override('c').contents, { 'a': { 'b': 1, 'd': 1 }, 'f': 1 });
|
||||
});
|
||||
@@ -111,7 +114,7 @@ suite('ConfigurationModel', () => {
|
||||
test('get overriding configuration model for an identifier that does not exist', () => {
|
||||
let testObject = new ConfigurationModel(
|
||||
{ 'a': { 'b': 1 }, 'f': 1 }, [],
|
||||
[{ identifiers: ['c'], contents: { 'a': { 'd': 1 } } }]);
|
||||
[{ identifiers: ['c'], contents: { 'a': { 'd': 1 } }, keys: ['a'] }]);
|
||||
|
||||
assert.deepEqual(testObject.override('xyz').contents, { 'a': { 'b': 1 }, 'f': 1 });
|
||||
});
|
||||
@@ -119,7 +122,7 @@ suite('ConfigurationModel', () => {
|
||||
test('get overriding configuration when one of the keys does not exist in base', () => {
|
||||
let testObject = new ConfigurationModel(
|
||||
{ 'a': { 'b': 1 }, 'f': 1 }, [],
|
||||
[{ identifiers: ['c'], contents: { 'a': { 'd': 1 }, 'g': 1 } }]);
|
||||
[{ identifiers: ['c'], contents: { 'a': { 'd': 1 }, 'g': 1 }, keys: ['a', 'g'] }]);
|
||||
|
||||
assert.deepEqual(testObject.override('c').contents, { 'a': { 'b': 1, 'd': 1 }, 'f': 1, 'g': 1 });
|
||||
});
|
||||
@@ -127,7 +130,7 @@ suite('ConfigurationModel', () => {
|
||||
test('get overriding configuration when one of the key in base is not of object type', () => {
|
||||
let testObject = new ConfigurationModel(
|
||||
{ 'a': { 'b': 1 }, 'f': 1 }, [],
|
||||
[{ identifiers: ['c'], contents: { 'a': { 'd': 1 }, 'f': { 'g': 1 } } }]);
|
||||
[{ identifiers: ['c'], contents: { 'a': { 'd': 1 }, 'f': { 'g': 1 } }, keys: ['a', 'f'] }]);
|
||||
|
||||
assert.deepEqual(testObject.override('c').contents, { 'a': { 'b': 1, 'd': 1 }, 'f': { 'g': 1 } });
|
||||
});
|
||||
@@ -135,7 +138,7 @@ suite('ConfigurationModel', () => {
|
||||
test('get overriding configuration when one of the key in overriding contents is not of object type', () => {
|
||||
let testObject = new ConfigurationModel(
|
||||
{ 'a': { 'b': 1 }, 'f': { 'g': 1 } }, [],
|
||||
[{ identifiers: ['c'], contents: { 'a': { 'd': 1 }, 'f': 1 } }]);
|
||||
[{ identifiers: ['c'], contents: { 'a': { 'd': 1 }, 'f': 1 }, keys: ['a', 'f'] }]);
|
||||
|
||||
assert.deepEqual(testObject.override('c').contents, { 'a': { 'b': 1, 'd': 1 }, 'f': 1 });
|
||||
});
|
||||
@@ -143,7 +146,7 @@ suite('ConfigurationModel', () => {
|
||||
test('get overriding configuration if the value of overriding identifier is not object', () => {
|
||||
let testObject = new ConfigurationModel(
|
||||
{ 'a': { 'b': 1 }, 'f': { 'g': 1 } }, [],
|
||||
[{ identifiers: ['c'], contents: 'abc' }]);
|
||||
[{ identifiers: ['c'], contents: 'abc', keys: [] }]);
|
||||
|
||||
assert.deepEqual(testObject.override('c').contents, { 'a': { 'b': 1 }, 'f': { 'g': 1 } });
|
||||
});
|
||||
@@ -151,7 +154,7 @@ suite('ConfigurationModel', () => {
|
||||
test('get overriding configuration if the value of overriding identifier is an empty object', () => {
|
||||
let testObject = new ConfigurationModel(
|
||||
{ 'a': { 'b': 1 }, 'f': { 'g': 1 } }, [],
|
||||
[{ identifiers: ['c'], contents: {} }]);
|
||||
[{ identifiers: ['c'], contents: {}, keys: [] }]);
|
||||
|
||||
assert.deepEqual(testObject.override('c').contents, { 'a': { 'b': 1 }, 'f': { 'g': 1 } });
|
||||
});
|
||||
@@ -176,34 +179,34 @@ suite('ConfigurationModel', () => {
|
||||
});
|
||||
|
||||
test('simple merge overrides', () => {
|
||||
let base = new ConfigurationModel({ 'a': { 'b': 1 } }, ['a.b'], [{ identifiers: ['c'], contents: { 'a': 2 } }]);
|
||||
let add = new ConfigurationModel({ 'a': { 'b': 2 } }, ['a.b'], [{ identifiers: ['c'], contents: { 'b': 2 } }]);
|
||||
let base = new ConfigurationModel({ 'a': { 'b': 1 } }, ['a.b'], [{ identifiers: ['c'], contents: { 'a': 2 }, keys: ['a'] }]);
|
||||
let add = new ConfigurationModel({ 'a': { 'b': 2 } }, ['a.b'], [{ identifiers: ['c'], contents: { 'b': 2 }, keys: ['b'] }]);
|
||||
let result = base.merge(add);
|
||||
|
||||
assert.deepEqual(result.contents, { 'a': { 'b': 2 } });
|
||||
assert.deepEqual(result.overrides, [{ identifiers: ['c'], contents: { 'a': 2, 'b': 2 } }]);
|
||||
assert.deepEqual(result.overrides, [{ identifiers: ['c'], contents: { 'a': 2, 'b': 2 }, keys: ['a'] }]);
|
||||
assert.deepEqual(result.override('c').contents, { 'a': 2, 'b': 2 });
|
||||
assert.deepEqual(result.keys, ['a.b']);
|
||||
});
|
||||
|
||||
test('recursive merge overrides', () => {
|
||||
let base = new ConfigurationModel({ 'a': { 'b': 1 }, 'f': 1 }, ['a.b', 'f'], [{ identifiers: ['c'], contents: { 'a': { 'd': 1 } } }]);
|
||||
let add = new ConfigurationModel({ 'a': { 'b': 2 } }, ['a.b'], [{ identifiers: ['c'], contents: { 'a': { 'e': 2 } } }]);
|
||||
let base = new ConfigurationModel({ 'a': { 'b': 1 }, 'f': 1 }, ['a.b', 'f'], [{ identifiers: ['c'], contents: { 'a': { 'd': 1 } }, keys: ['a'] }]);
|
||||
let add = new ConfigurationModel({ 'a': { 'b': 2 } }, ['a.b'], [{ identifiers: ['c'], contents: { 'a': { 'e': 2 } }, keys: ['a'] }]);
|
||||
let result = base.merge(add);
|
||||
|
||||
assert.deepEqual(result.contents, { 'a': { 'b': 2 }, 'f': 1 });
|
||||
assert.deepEqual(result.overrides, [{ identifiers: ['c'], contents: { 'a': { 'd': 1, 'e': 2 } } }]);
|
||||
assert.deepEqual(result.overrides, [{ identifiers: ['c'], contents: { 'a': { 'd': 1, 'e': 2 } }, keys: ['a'] }]);
|
||||
assert.deepEqual(result.override('c').contents, { 'a': { 'b': 2, 'd': 1, 'e': 2 }, 'f': 1 });
|
||||
assert.deepEqual(result.keys, ['a.b', 'f']);
|
||||
});
|
||||
|
||||
test('merge overrides when frozen', () => {
|
||||
let model1 = new ConfigurationModel({ 'a': { 'b': 1 }, 'f': 1 }, ['a.b', 'f'], [{ identifiers: ['c'], contents: { 'a': { 'd': 1 } } }]).freeze();
|
||||
let model2 = new ConfigurationModel({ 'a': { 'b': 2 } }, ['a.b'], [{ identifiers: ['c'], contents: { 'a': { 'e': 2 } } }]).freeze();
|
||||
let model1 = new ConfigurationModel({ 'a': { 'b': 1 }, 'f': 1 }, ['a.b', 'f'], [{ identifiers: ['c'], contents: { 'a': { 'd': 1 } }, keys: ['a'] }]).freeze();
|
||||
let model2 = new ConfigurationModel({ 'a': { 'b': 2 } }, ['a.b'], [{ identifiers: ['c'], contents: { 'a': { 'e': 2 } }, keys: ['a'] }]).freeze();
|
||||
let result = new ConfigurationModel().merge(model1, model2);
|
||||
|
||||
assert.deepEqual(result.contents, { 'a': { 'b': 2 }, 'f': 1 });
|
||||
assert.deepEqual(result.overrides, [{ identifiers: ['c'], contents: { 'a': { 'd': 1, 'e': 2 } } }]);
|
||||
assert.deepEqual(result.overrides, [{ identifiers: ['c'], contents: { 'a': { 'd': 1, 'e': 2 } }, keys: ['a'] }]);
|
||||
assert.deepEqual(result.override('c').contents, { 'a': { 'b': 2, 'd': 1, 'e': 2 }, 'f': 1 });
|
||||
assert.deepEqual(result.keys, ['a.b', 'f']);
|
||||
});
|
||||
@@ -223,7 +226,7 @@ suite('ConfigurationModel', () => {
|
||||
});
|
||||
|
||||
test('Test override gives all content merged with overrides', () => {
|
||||
const testObject = new ConfigurationModel({ 'a': 1, 'c': 1 }, [], [{ identifiers: ['b'], contents: { 'a': 2 } }]);
|
||||
const testObject = new ConfigurationModel({ 'a': 1, 'c': 1 }, [], [{ identifiers: ['b'], contents: { 'a': 2 }, keys: ['a'] }]);
|
||||
|
||||
assert.deepEqual(testObject.override('b').contents, { 'a': 2, 'c': 1 });
|
||||
});
|
||||
@@ -360,114 +363,6 @@ suite('CustomConfigurationModel', () => {
|
||||
});
|
||||
});
|
||||
|
||||
suite('ConfigurationChangeEvent', () => {
|
||||
|
||||
test('changeEvent affecting keys for all resources', () => {
|
||||
let testObject = new ConfigurationChangeEvent();
|
||||
|
||||
testObject.change(['window.zoomLevel', 'workbench.editor.enablePreview', 'files', '[markdown]']);
|
||||
|
||||
assert.deepEqual(testObject.affectedKeys, ['window.zoomLevel', 'workbench.editor.enablePreview', 'files', '[markdown]']);
|
||||
assert.ok(testObject.affectsConfiguration('window.zoomLevel'));
|
||||
assert.ok(testObject.affectsConfiguration('window'));
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor.enablePreview'));
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor'));
|
||||
assert.ok(testObject.affectsConfiguration('workbench'));
|
||||
assert.ok(testObject.affectsConfiguration('files'));
|
||||
assert.ok(!testObject.affectsConfiguration('files.exclude'));
|
||||
assert.ok(testObject.affectsConfiguration('[markdown]'));
|
||||
});
|
||||
|
||||
test('changeEvent affecting a root key and its children', () => {
|
||||
let testObject = new ConfigurationChangeEvent();
|
||||
|
||||
testObject.change(['launch', 'launch.version', 'tasks']);
|
||||
|
||||
assert.deepEqual(testObject.affectedKeys, ['launch.version', 'tasks']);
|
||||
assert.ok(testObject.affectsConfiguration('launch'));
|
||||
assert.ok(testObject.affectsConfiguration('launch.version'));
|
||||
assert.ok(testObject.affectsConfiguration('tasks'));
|
||||
});
|
||||
|
||||
test('changeEvent affecting keys for resources', () => {
|
||||
let testObject = new ConfigurationChangeEvent();
|
||||
|
||||
testObject.change(['window.title']);
|
||||
testObject.change(['window.zoomLevel'], URI.file('file1'));
|
||||
testObject.change(['workbench.editor.enablePreview'], URI.file('file2'));
|
||||
testObject.change(['window.restoreFullscreen'], URI.file('file1'));
|
||||
testObject.change(['window.restoreWindows'], URI.file('file2'));
|
||||
|
||||
assert.deepEqual(testObject.affectedKeys, ['window.title', 'window.zoomLevel', 'window.restoreFullscreen', 'workbench.editor.enablePreview', 'window.restoreWindows']);
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('window.zoomLevel'));
|
||||
assert.ok(testObject.affectsConfiguration('window.zoomLevel', URI.file('file1')));
|
||||
assert.ok(!testObject.affectsConfiguration('window.zoomLevel', URI.file('file2')));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('window.restoreFullscreen'));
|
||||
assert.ok(testObject.affectsConfiguration('window.restoreFullscreen', URI.file('file1')));
|
||||
assert.ok(!testObject.affectsConfiguration('window.restoreFullscreen', URI.file('file2')));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('window.restoreWindows'));
|
||||
assert.ok(testObject.affectsConfiguration('window.restoreWindows', URI.file('file2')));
|
||||
assert.ok(!testObject.affectsConfiguration('window.restoreWindows', URI.file('file1')));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('window.title'));
|
||||
assert.ok(testObject.affectsConfiguration('window.title', URI.file('file1')));
|
||||
assert.ok(testObject.affectsConfiguration('window.title', URI.file('file2')));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('window'));
|
||||
assert.ok(testObject.affectsConfiguration('window', URI.file('file1')));
|
||||
assert.ok(testObject.affectsConfiguration('window', URI.file('file2')));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor.enablePreview'));
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor.enablePreview', URI.file('file2')));
|
||||
assert.ok(!testObject.affectsConfiguration('workbench.editor.enablePreview', URI.file('file1')));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor'));
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor', URI.file('file2')));
|
||||
assert.ok(!testObject.affectsConfiguration('workbench.editor', URI.file('file1')));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('workbench'));
|
||||
assert.ok(testObject.affectsConfiguration('workbench', URI.file('file2')));
|
||||
assert.ok(!testObject.affectsConfiguration('workbench', URI.file('file1')));
|
||||
|
||||
assert.ok(!testObject.affectsConfiguration('files'));
|
||||
assert.ok(!testObject.affectsConfiguration('files', URI.file('file1')));
|
||||
assert.ok(!testObject.affectsConfiguration('files', URI.file('file2')));
|
||||
});
|
||||
|
||||
test('merging change events', () => {
|
||||
let event1 = new ConfigurationChangeEvent().change(['window.zoomLevel', 'files']);
|
||||
let event2 = new ConfigurationChangeEvent().change(['window.title'], URI.file('file1')).change(['[markdown]']);
|
||||
|
||||
let actual = event1.change(event2);
|
||||
|
||||
assert.deepEqual(actual.affectedKeys, ['window.zoomLevel', 'files', '[markdown]', 'window.title']);
|
||||
|
||||
assert.ok(actual.affectsConfiguration('window.zoomLevel'));
|
||||
assert.ok(actual.affectsConfiguration('window.zoomLevel', URI.file('file1')));
|
||||
assert.ok(actual.affectsConfiguration('window.zoomLevel', URI.file('file2')));
|
||||
|
||||
assert.ok(actual.affectsConfiguration('window'));
|
||||
assert.ok(actual.affectsConfiguration('window', URI.file('file1')));
|
||||
assert.ok(actual.affectsConfiguration('window', URI.file('file2')));
|
||||
|
||||
assert.ok(actual.affectsConfiguration('files'));
|
||||
assert.ok(actual.affectsConfiguration('files', URI.file('file1')));
|
||||
assert.ok(actual.affectsConfiguration('files', URI.file('file2')));
|
||||
|
||||
assert.ok(actual.affectsConfiguration('window.title'));
|
||||
assert.ok(actual.affectsConfiguration('window.title', URI.file('file1')));
|
||||
assert.ok(!actual.affectsConfiguration('window.title', URI.file('file2')));
|
||||
|
||||
assert.ok(actual.affectsConfiguration('[markdown]'));
|
||||
assert.ok(actual.affectsConfiguration('[markdown]', URI.file('file1')));
|
||||
assert.ok(actual.affectsConfiguration('[markdown]', URI.file('file2')));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
suite('Configuration', () => {
|
||||
|
||||
test('Test update value', () => {
|
||||
@@ -491,5 +386,552 @@ suite('Configuration', () => {
|
||||
assert.equal(testObject.getValue('a', {}, undefined), 2);
|
||||
});
|
||||
|
||||
test('Test compare and update default configuration', () => {
|
||||
const testObject = new Configuration(new ConfigurationModel(), new ConfigurationModel());
|
||||
testObject.updateDefaultConfiguration(toConfigurationModel({
|
||||
'editor.lineNumbers': 'on',
|
||||
}));
|
||||
|
||||
});
|
||||
const actual = testObject.compareAndUpdateDefaultConfiguration(toConfigurationModel({
|
||||
'editor.lineNumbers': 'off',
|
||||
'[markdown]': {
|
||||
'editor.wordWrap': 'off'
|
||||
}
|
||||
}), ['editor.lineNumbers', '[markdown]']);
|
||||
|
||||
assert.deepEqual(actual, { keys: ['editor.lineNumbers', '[markdown]'], overrides: [['markdown', ['editor.wordWrap']]] });
|
||||
|
||||
});
|
||||
|
||||
test('Test compare and update user configuration', () => {
|
||||
const testObject = new Configuration(new ConfigurationModel(), new ConfigurationModel());
|
||||
testObject.updateLocalUserConfiguration(toConfigurationModel({
|
||||
'editor.lineNumbers': 'off',
|
||||
'editor.fontSize': 12,
|
||||
'[typescript]': {
|
||||
'editor.wordWrap': 'off'
|
||||
}
|
||||
}));
|
||||
|
||||
const actual = testObject.compareAndUpdateLocalUserConfiguration(toConfigurationModel({
|
||||
'editor.lineNumbers': 'on',
|
||||
'window.zoomLevel': 1,
|
||||
'[typescript]': {
|
||||
'editor.wordWrap': 'on',
|
||||
'editor.insertSpaces': false
|
||||
}
|
||||
}));
|
||||
|
||||
assert.deepEqual(actual, { keys: ['window.zoomLevel', 'editor.lineNumbers', '[typescript]', 'editor.fontSize'], overrides: [['typescript', ['editor.insertSpaces', 'editor.wordWrap']]] });
|
||||
|
||||
});
|
||||
|
||||
test('Test compare and update workspace configuration', () => {
|
||||
const testObject = new Configuration(new ConfigurationModel(), new ConfigurationModel());
|
||||
testObject.updateWorkspaceConfiguration(toConfigurationModel({
|
||||
'editor.lineNumbers': 'off',
|
||||
'editor.fontSize': 12,
|
||||
'[typescript]': {
|
||||
'editor.wordWrap': 'off'
|
||||
}
|
||||
}));
|
||||
|
||||
const actual = testObject.compareAndUpdateWorkspaceConfiguration(toConfigurationModel({
|
||||
'editor.lineNumbers': 'on',
|
||||
'window.zoomLevel': 1,
|
||||
'[typescript]': {
|
||||
'editor.wordWrap': 'on',
|
||||
'editor.insertSpaces': false
|
||||
}
|
||||
}));
|
||||
|
||||
assert.deepEqual(actual, { keys: ['window.zoomLevel', 'editor.lineNumbers', '[typescript]', 'editor.fontSize'], overrides: [['typescript', ['editor.insertSpaces', 'editor.wordWrap']]] });
|
||||
|
||||
});
|
||||
|
||||
test('Test compare and update workspace folder configuration', () => {
|
||||
const testObject = new Configuration(new ConfigurationModel(), new ConfigurationModel());
|
||||
testObject.updateFolderConfiguration(URI.file('file1'), toConfigurationModel({
|
||||
'editor.lineNumbers': 'off',
|
||||
'editor.fontSize': 12,
|
||||
'[typescript]': {
|
||||
'editor.wordWrap': 'off'
|
||||
}
|
||||
}));
|
||||
|
||||
const actual = testObject.compareAndUpdateFolderConfiguration(URI.file('file1'), toConfigurationModel({
|
||||
'editor.lineNumbers': 'on',
|
||||
'window.zoomLevel': 1,
|
||||
'[typescript]': {
|
||||
'editor.wordWrap': 'on',
|
||||
'editor.insertSpaces': false
|
||||
}
|
||||
}));
|
||||
|
||||
assert.deepEqual(actual, { keys: ['window.zoomLevel', 'editor.lineNumbers', '[typescript]', 'editor.fontSize'], overrides: [['typescript', ['editor.insertSpaces', 'editor.wordWrap']]] });
|
||||
|
||||
});
|
||||
|
||||
test('Test compare and deletre workspace folder configuration', () => {
|
||||
const testObject = new Configuration(new ConfigurationModel(), new ConfigurationModel());
|
||||
testObject.updateFolderConfiguration(URI.file('file1'), toConfigurationModel({
|
||||
'editor.lineNumbers': 'off',
|
||||
'editor.fontSize': 12,
|
||||
'[typescript]': {
|
||||
'editor.wordWrap': 'off'
|
||||
}
|
||||
}));
|
||||
|
||||
const actual = testObject.compareAndDeleteFolderConfiguration(URI.file('file1'));
|
||||
|
||||
assert.deepEqual(actual, { keys: ['editor.lineNumbers', 'editor.fontSize', '[typescript]'], overrides: [['typescript', ['editor.wordWrap']]] });
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
suite('ConfigurationChangeEvent', () => {
|
||||
|
||||
test('changeEvent affecting keys with new configuration', () => {
|
||||
const configuration = new Configuration(new ConfigurationModel(), new ConfigurationModel());
|
||||
const change = configuration.compareAndUpdateLocalUserConfiguration(toConfigurationModel({
|
||||
'window.zoomLevel': 1,
|
||||
'workbench.editor.enablePreview': false,
|
||||
'files.autoSave': 'off',
|
||||
}));
|
||||
let testObject = new ConfigurationChangeEvent(change, undefined, configuration);
|
||||
|
||||
assert.deepEqual(testObject.affectedKeys, ['window.zoomLevel', 'workbench.editor.enablePreview', 'files.autoSave']);
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('window.zoomLevel'));
|
||||
assert.ok(testObject.affectsConfiguration('window'));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor.enablePreview'));
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor'));
|
||||
assert.ok(testObject.affectsConfiguration('workbench'));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('files'));
|
||||
assert.ok(testObject.affectsConfiguration('files.autoSave'));
|
||||
assert.ok(!testObject.affectsConfiguration('files.exclude'));
|
||||
|
||||
assert.ok(!testObject.affectsConfiguration('[markdown]'));
|
||||
assert.ok(!testObject.affectsConfiguration('editor'));
|
||||
});
|
||||
|
||||
test('changeEvent affecting keys when configuration changed', () => {
|
||||
const configuration = new Configuration(new ConfigurationModel(), new ConfigurationModel());
|
||||
configuration.updateLocalUserConfiguration(toConfigurationModel({
|
||||
'window.zoomLevel': 2,
|
||||
'workbench.editor.enablePreview': true,
|
||||
'files.autoSave': 'off',
|
||||
}));
|
||||
const data = configuration.toData();
|
||||
const change = configuration.compareAndUpdateLocalUserConfiguration(toConfigurationModel({
|
||||
'window.zoomLevel': 1,
|
||||
'workbench.editor.enablePreview': false,
|
||||
'files.autoSave': 'off',
|
||||
}));
|
||||
let testObject = new ConfigurationChangeEvent(change, { data }, configuration);
|
||||
|
||||
assert.deepEqual(testObject.affectedKeys, ['window.zoomLevel', 'workbench.editor.enablePreview']);
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('window.zoomLevel'));
|
||||
assert.ok(testObject.affectsConfiguration('window'));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor.enablePreview'));
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor'));
|
||||
assert.ok(testObject.affectsConfiguration('workbench'));
|
||||
|
||||
assert.ok(!testObject.affectsConfiguration('files'));
|
||||
assert.ok(!testObject.affectsConfiguration('[markdown]'));
|
||||
assert.ok(!testObject.affectsConfiguration('editor'));
|
||||
});
|
||||
|
||||
test('changeEvent affecting overrides with new configuration', () => {
|
||||
const configuration = new Configuration(new ConfigurationModel(), new ConfigurationModel());
|
||||
const change = configuration.compareAndUpdateLocalUserConfiguration(toConfigurationModel({
|
||||
'files.autoSave': 'off',
|
||||
'[markdown]': {
|
||||
'editor.wordWrap': 'off'
|
||||
}
|
||||
}));
|
||||
let testObject = new ConfigurationChangeEvent(change, undefined, configuration);
|
||||
|
||||
assert.deepEqual(testObject.affectedKeys, ['files.autoSave', '[markdown]', 'editor.wordWrap']);
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('files'));
|
||||
assert.ok(testObject.affectsConfiguration('files.autoSave'));
|
||||
assert.ok(!testObject.affectsConfiguration('files.exclude'));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('[markdown]'));
|
||||
assert.ok(!testObject.affectsConfiguration('[markdown].editor'));
|
||||
assert.ok(!testObject.affectsConfiguration('[markdown].workbench'));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('editor'));
|
||||
assert.ok(testObject.affectsConfiguration('editor.wordWrap'));
|
||||
assert.ok(testObject.affectsConfiguration('editor', { overrideIdentifier: 'markdown' }));
|
||||
assert.ok(testObject.affectsConfiguration('editor.wordWrap', { overrideIdentifier: 'markdown' }));
|
||||
assert.ok(!testObject.affectsConfiguration('editor', { overrideIdentifier: 'json' }));
|
||||
assert.ok(!testObject.affectsConfiguration('editor.fontSize', { overrideIdentifier: 'markdown' }));
|
||||
|
||||
assert.ok(!testObject.affectsConfiguration('editor.fontSize'));
|
||||
assert.ok(!testObject.affectsConfiguration('window'));
|
||||
});
|
||||
|
||||
test('changeEvent affecting overrides when configuration changed', () => {
|
||||
const configuration = new Configuration(new ConfigurationModel(), new ConfigurationModel());
|
||||
configuration.updateLocalUserConfiguration(toConfigurationModel({
|
||||
'workbench.editor.enablePreview': true,
|
||||
'[markdown]': {
|
||||
'editor.fontSize': 12,
|
||||
'editor.wordWrap': 'off'
|
||||
},
|
||||
'files.autoSave': 'off',
|
||||
}));
|
||||
const data = configuration.toData();
|
||||
const change = configuration.compareAndUpdateLocalUserConfiguration(toConfigurationModel({
|
||||
'files.autoSave': 'off',
|
||||
'[markdown]': {
|
||||
'editor.fontSize': 13,
|
||||
'editor.wordWrap': 'off'
|
||||
},
|
||||
'window.zoomLevel': 1,
|
||||
}));
|
||||
let testObject = new ConfigurationChangeEvent(change, { data }, configuration);
|
||||
|
||||
assert.deepEqual(testObject.affectedKeys, ['window.zoomLevel', '[markdown]', 'workbench.editor.enablePreview', 'editor.fontSize']);
|
||||
|
||||
assert.ok(!testObject.affectsConfiguration('files'));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('[markdown]'));
|
||||
assert.ok(!testObject.affectsConfiguration('[markdown].editor'));
|
||||
assert.ok(!testObject.affectsConfiguration('[markdown].editor.fontSize'));
|
||||
assert.ok(!testObject.affectsConfiguration('[markdown].editor.wordWrap'));
|
||||
assert.ok(!testObject.affectsConfiguration('[markdown].workbench'));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('editor'));
|
||||
assert.ok(testObject.affectsConfiguration('editor', { overrideIdentifier: 'markdown' }));
|
||||
assert.ok(testObject.affectsConfiguration('editor.fontSize', { overrideIdentifier: 'markdown' }));
|
||||
assert.ok(!testObject.affectsConfiguration('editor.wordWrap'));
|
||||
assert.ok(!testObject.affectsConfiguration('editor.wordWrap', { overrideIdentifier: 'markdown' }));
|
||||
assert.ok(!testObject.affectsConfiguration('editor', { overrideIdentifier: 'json' }));
|
||||
assert.ok(!testObject.affectsConfiguration('editor.fontSize', { overrideIdentifier: 'json' }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('window'));
|
||||
assert.ok(testObject.affectsConfiguration('window.zoomLevel'));
|
||||
assert.ok(testObject.affectsConfiguration('window', { overrideIdentifier: 'markdown' }));
|
||||
assert.ok(testObject.affectsConfiguration('window.zoomLevel', { overrideIdentifier: 'markdown' }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('workbench'));
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor'));
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor.enablePreview'));
|
||||
assert.ok(testObject.affectsConfiguration('workbench', { overrideIdentifier: 'markdown' }));
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor', { overrideIdentifier: 'markdown' }));
|
||||
});
|
||||
|
||||
test('changeEvent affecting workspace folders', () => {
|
||||
const configuration = new Configuration(new ConfigurationModel(), new ConfigurationModel());
|
||||
configuration.updateWorkspaceConfiguration(toConfigurationModel({ 'window.title': 'custom' }));
|
||||
configuration.updateFolderConfiguration(URI.file('folder1'), toConfigurationModel({ 'window.zoomLevel': 2, 'window.restoreFullscreen': true }));
|
||||
configuration.updateFolderConfiguration(URI.file('folder2'), toConfigurationModel({ 'workbench.editor.enablePreview': true, 'window.restoreWindows': true }));
|
||||
const data = configuration.toData();
|
||||
const workspace = new Workspace('a', [new WorkspaceFolder({ index: 0, name: 'a', uri: URI.file('folder1') }), new WorkspaceFolder({ index: 1, name: 'b', uri: URI.file('folder2') }), new WorkspaceFolder({ index: 2, name: 'c', uri: URI.file('folder3') })]);
|
||||
const change = mergeChanges(
|
||||
configuration.compareAndUpdateWorkspaceConfiguration(toConfigurationModel({ 'window.title': 'native' })),
|
||||
configuration.compareAndUpdateFolderConfiguration(URI.file('folder1'), toConfigurationModel({ 'window.zoomLevel': 1, 'window.restoreFullscreen': false })),
|
||||
configuration.compareAndUpdateFolderConfiguration(URI.file('folder2'), toConfigurationModel({ 'workbench.editor.enablePreview': false, 'window.restoreWindows': false }))
|
||||
);
|
||||
let testObject = new ConfigurationChangeEvent(change, { data, workspace }, configuration, workspace);
|
||||
|
||||
assert.deepEqual(testObject.affectedKeys, ['window.title', 'window.zoomLevel', 'window.restoreFullscreen', 'workbench.editor.enablePreview', 'window.restoreWindows']);
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('window.zoomLevel'));
|
||||
assert.ok(testObject.affectsConfiguration('window.zoomLevel', { resource: URI.file('folder1') }));
|
||||
assert.ok(testObject.affectsConfiguration('window.zoomLevel', { resource: URI.file(join('folder1', 'file1')) }));
|
||||
assert.ok(!testObject.affectsConfiguration('window.zoomLevel', { resource: URI.file('file1') }));
|
||||
assert.ok(!testObject.affectsConfiguration('window.zoomLevel', { resource: URI.file('file2') }));
|
||||
assert.ok(!testObject.affectsConfiguration('window.zoomLevel', { resource: URI.file(join('folder2', 'file2')) }));
|
||||
assert.ok(!testObject.affectsConfiguration('window.zoomLevel', { resource: URI.file(join('folder3', 'file3')) }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('window.restoreFullscreen'));
|
||||
assert.ok(testObject.affectsConfiguration('window.restoreFullscreen', { resource: URI.file(join('folder1', 'file1')) }));
|
||||
assert.ok(testObject.affectsConfiguration('window.restoreFullscreen', { resource: URI.file('folder1') }));
|
||||
assert.ok(!testObject.affectsConfiguration('window.restoreFullscreen', { resource: URI.file('file1') }));
|
||||
assert.ok(!testObject.affectsConfiguration('window.restoreFullscreen', { resource: URI.file('file2') }));
|
||||
assert.ok(!testObject.affectsConfiguration('window.restoreFullscreen', { resource: URI.file(join('folder2', 'file2')) }));
|
||||
assert.ok(!testObject.affectsConfiguration('window.restoreFullscreen', { resource: URI.file(join('folder3', 'file3')) }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('window.restoreWindows'));
|
||||
assert.ok(testObject.affectsConfiguration('window.restoreWindows', { resource: URI.file('folder2') }));
|
||||
assert.ok(testObject.affectsConfiguration('window.restoreWindows', { resource: URI.file(join('folder2', 'file2')) }));
|
||||
assert.ok(!testObject.affectsConfiguration('window.restoreWindows', { resource: URI.file('file2') }));
|
||||
assert.ok(!testObject.affectsConfiguration('window.restoreWindows', { resource: URI.file(join('folder1', 'file1')) }));
|
||||
assert.ok(!testObject.affectsConfiguration('window.restoreWindows', { resource: URI.file(join('folder3', 'file3')) }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('window.title'));
|
||||
assert.ok(testObject.affectsConfiguration('window.title', { resource: URI.file('folder1') }));
|
||||
assert.ok(testObject.affectsConfiguration('window.title', { resource: URI.file(join('folder1', 'file1')) }));
|
||||
assert.ok(testObject.affectsConfiguration('window.title', { resource: URI.file('folder2') }));
|
||||
assert.ok(testObject.affectsConfiguration('window.title', { resource: URI.file(join('folder2', 'file2')) }));
|
||||
assert.ok(testObject.affectsConfiguration('window.title', { resource: URI.file('folder3') }));
|
||||
assert.ok(testObject.affectsConfiguration('window.title', { resource: URI.file(join('folder3', 'file3')) }));
|
||||
assert.ok(testObject.affectsConfiguration('window.title', { resource: URI.file('file1') }));
|
||||
assert.ok(testObject.affectsConfiguration('window.title', { resource: URI.file('file2') }));
|
||||
assert.ok(testObject.affectsConfiguration('window.title', { resource: URI.file('file3') }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('window'));
|
||||
assert.ok(testObject.affectsConfiguration('window', { resource: URI.file('folder1') }));
|
||||
assert.ok(testObject.affectsConfiguration('window', { resource: URI.file(join('folder1', 'file1')) }));
|
||||
assert.ok(testObject.affectsConfiguration('window', { resource: URI.file('folder2') }));
|
||||
assert.ok(testObject.affectsConfiguration('window', { resource: URI.file(join('folder2', 'file2')) }));
|
||||
assert.ok(testObject.affectsConfiguration('window', { resource: URI.file('folder3') }));
|
||||
assert.ok(testObject.affectsConfiguration('window', { resource: URI.file(join('folder3', 'file3')) }));
|
||||
assert.ok(testObject.affectsConfiguration('window', { resource: URI.file('file1') }));
|
||||
assert.ok(testObject.affectsConfiguration('window', { resource: URI.file('file2') }));
|
||||
assert.ok(testObject.affectsConfiguration('window', { resource: URI.file('file3') }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor.enablePreview'));
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor.enablePreview', { resource: URI.file('folder2') }));
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor.enablePreview', { resource: URI.file(join('folder2', 'file2')) }));
|
||||
assert.ok(!testObject.affectsConfiguration('workbench.editor.enablePreview', { resource: URI.file('folder1') }));
|
||||
assert.ok(!testObject.affectsConfiguration('workbench.editor.enablePreview', { resource: URI.file(join('folder1', 'file1')) }));
|
||||
assert.ok(!testObject.affectsConfiguration('workbench.editor.enablePreview', { resource: URI.file('folder3') }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor'));
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor', { resource: URI.file('folder2') }));
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor', { resource: URI.file(join('folder2', 'file2')) }));
|
||||
assert.ok(!testObject.affectsConfiguration('workbench.editor', { resource: URI.file('folder1') }));
|
||||
assert.ok(!testObject.affectsConfiguration('workbench.editor', { resource: URI.file(join('folder1', 'file1')) }));
|
||||
assert.ok(!testObject.affectsConfiguration('workbench.editor', { resource: URI.file('folder3') }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('workbench'));
|
||||
assert.ok(testObject.affectsConfiguration('workbench', { resource: URI.file('folder2') }));
|
||||
assert.ok(testObject.affectsConfiguration('workbench', { resource: URI.file(join('folder2', 'file2')) }));
|
||||
assert.ok(!testObject.affectsConfiguration('workbench', { resource: URI.file('folder1') }));
|
||||
assert.ok(!testObject.affectsConfiguration('workbench', { resource: URI.file('folder3') }));
|
||||
|
||||
assert.ok(!testObject.affectsConfiguration('files'));
|
||||
assert.ok(!testObject.affectsConfiguration('files', { resource: URI.file('folder1') }));
|
||||
assert.ok(!testObject.affectsConfiguration('files', { resource: URI.file(join('folder1', 'file1')) }));
|
||||
assert.ok(!testObject.affectsConfiguration('files', { resource: URI.file('folder2') }));
|
||||
assert.ok(!testObject.affectsConfiguration('files', { resource: URI.file(join('folder2', 'file2')) }));
|
||||
assert.ok(!testObject.affectsConfiguration('files', { resource: URI.file('folder3') }));
|
||||
assert.ok(!testObject.affectsConfiguration('files', { resource: URI.file(join('folder3', 'file3')) }));
|
||||
});
|
||||
|
||||
test('changeEvent - all', () => {
|
||||
const configuration = new Configuration(new ConfigurationModel(), new ConfigurationModel());
|
||||
configuration.updateFolderConfiguration(URI.file('file1'), toConfigurationModel({ 'window.zoomLevel': 2, 'window.restoreFullscreen': true }));
|
||||
const data = configuration.toData();
|
||||
const change = mergeChanges(
|
||||
configuration.compareAndUpdateDefaultConfiguration(toConfigurationModel({
|
||||
'editor.lineNumbers': 'off',
|
||||
'[markdown]': {
|
||||
'editor.wordWrap': 'off'
|
||||
}
|
||||
}), ['editor.lineNumbers', '[markdown]']),
|
||||
configuration.compareAndUpdateLocalUserConfiguration(toConfigurationModel({
|
||||
'[json]': {
|
||||
'editor.lineNumbers': 'relative'
|
||||
}
|
||||
})),
|
||||
configuration.compareAndUpdateWorkspaceConfiguration(toConfigurationModel({ 'window.title': 'custom' })),
|
||||
configuration.compareAndDeleteFolderConfiguration(URI.file('file1')),
|
||||
configuration.compareAndUpdateFolderConfiguration(URI.file('file2'), toConfigurationModel({ 'workbench.editor.enablePreview': true, 'window.restoreWindows': true })));
|
||||
const workspace = new Workspace('a', [new WorkspaceFolder({ index: 0, name: 'a', uri: URI.file('file1') }), new WorkspaceFolder({ index: 1, name: 'b', uri: URI.file('file2') }), new WorkspaceFolder({ index: 2, name: 'c', uri: URI.file('folder3') })]);
|
||||
const testObject = new ConfigurationChangeEvent(change, { data, workspace }, configuration, workspace);
|
||||
|
||||
assert.deepEqual(testObject.affectedKeys, ['editor.lineNumbers', '[markdown]', '[json]', 'window.title', 'window.zoomLevel', 'window.restoreFullscreen', 'workbench.editor.enablePreview', 'window.restoreWindows', 'editor.wordWrap']);
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('window.title'));
|
||||
assert.ok(testObject.affectsConfiguration('window.title', { resource: URI.file('file1') }));
|
||||
assert.ok(testObject.affectsConfiguration('window.title', { resource: URI.file('file2') }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('window'));
|
||||
assert.ok(testObject.affectsConfiguration('window', { resource: URI.file('file1') }));
|
||||
assert.ok(testObject.affectsConfiguration('window', { resource: URI.file('file2') }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('window.zoomLevel'));
|
||||
assert.ok(testObject.affectsConfiguration('window.zoomLevel', { resource: URI.file('file1') }));
|
||||
assert.ok(!testObject.affectsConfiguration('window.zoomLevel', { resource: URI.file('file2') }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('window.restoreFullscreen'));
|
||||
assert.ok(testObject.affectsConfiguration('window.restoreFullscreen', { resource: URI.file('file1') }));
|
||||
assert.ok(!testObject.affectsConfiguration('window.restoreFullscreen', { resource: URI.file('file2') }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('window.restoreWindows'));
|
||||
assert.ok(testObject.affectsConfiguration('window.restoreWindows', { resource: URI.file('file2') }));
|
||||
assert.ok(!testObject.affectsConfiguration('window.restoreWindows', { resource: URI.file('file1') }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor.enablePreview'));
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor.enablePreview', { resource: URI.file('file2') }));
|
||||
assert.ok(!testObject.affectsConfiguration('workbench.editor.enablePreview', { resource: URI.file('file1') }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor'));
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor', { resource: URI.file('file2') }));
|
||||
assert.ok(!testObject.affectsConfiguration('workbench.editor', { resource: URI.file('file1') }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('workbench'));
|
||||
assert.ok(testObject.affectsConfiguration('workbench', { resource: URI.file('file2') }));
|
||||
assert.ok(!testObject.affectsConfiguration('workbench', { resource: URI.file('file1') }));
|
||||
|
||||
assert.ok(!testObject.affectsConfiguration('files'));
|
||||
assert.ok(!testObject.affectsConfiguration('files', { resource: URI.file('file1') }));
|
||||
assert.ok(!testObject.affectsConfiguration('files', { resource: URI.file('file2') }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('editor'));
|
||||
assert.ok(testObject.affectsConfiguration('editor', { resource: URI.file('file1') }));
|
||||
assert.ok(testObject.affectsConfiguration('editor', { resource: URI.file('file2') }));
|
||||
assert.ok(testObject.affectsConfiguration('editor', { resource: URI.file('file1'), overrideIdentifier: 'json' }));
|
||||
assert.ok(testObject.affectsConfiguration('editor', { resource: URI.file('file1'), overrideIdentifier: 'markdown' }));
|
||||
assert.ok(testObject.affectsConfiguration('editor', { resource: URI.file('file1'), overrideIdentifier: 'typescript' }));
|
||||
assert.ok(testObject.affectsConfiguration('editor', { resource: URI.file('file2'), overrideIdentifier: 'json' }));
|
||||
assert.ok(testObject.affectsConfiguration('editor', { resource: URI.file('file2'), overrideIdentifier: 'markdown' }));
|
||||
assert.ok(testObject.affectsConfiguration('editor', { resource: URI.file('file2'), overrideIdentifier: 'typescript' }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('editor.lineNumbers'));
|
||||
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { resource: URI.file('file1') }));
|
||||
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { resource: URI.file('file2') }));
|
||||
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { resource: URI.file('file1'), overrideIdentifier: 'json' }));
|
||||
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { resource: URI.file('file1'), overrideIdentifier: 'markdown' }));
|
||||
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { resource: URI.file('file1'), overrideIdentifier: 'typescript' }));
|
||||
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { resource: URI.file('file2'), overrideIdentifier: 'json' }));
|
||||
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { resource: URI.file('file2'), overrideIdentifier: 'markdown' }));
|
||||
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { resource: URI.file('file2'), overrideIdentifier: 'typescript' }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('editor.wordWrap'));
|
||||
assert.ok(!testObject.affectsConfiguration('editor.wordWrap', { resource: URI.file('file1') }));
|
||||
assert.ok(!testObject.affectsConfiguration('editor.wordWrap', { resource: URI.file('file2') }));
|
||||
assert.ok(!testObject.affectsConfiguration('editor.wordWrap', { resource: URI.file('file1'), overrideIdentifier: 'json' }));
|
||||
assert.ok(testObject.affectsConfiguration('editor.wordWrap', { resource: URI.file('file1'), overrideIdentifier: 'markdown' }));
|
||||
assert.ok(!testObject.affectsConfiguration('editor.wordWrap', { resource: URI.file('file1'), overrideIdentifier: 'typescript' }));
|
||||
assert.ok(!testObject.affectsConfiguration('editor.wordWrap', { resource: URI.file('file2'), overrideIdentifier: 'json' }));
|
||||
assert.ok(testObject.affectsConfiguration('editor.wordWrap', { resource: URI.file('file2'), overrideIdentifier: 'markdown' }));
|
||||
assert.ok(!testObject.affectsConfiguration('editor.wordWrap', { resource: URI.file('file2'), overrideIdentifier: 'typescript' }));
|
||||
|
||||
assert.ok(!testObject.affectsConfiguration('editor.fontSize'));
|
||||
assert.ok(!testObject.affectsConfiguration('editor.fontSize', { resource: URI.file('file1') }));
|
||||
assert.ok(!testObject.affectsConfiguration('editor.fontSize', { resource: URI.file('file2') }));
|
||||
});
|
||||
|
||||
test('changeEvent affecting tasks and launches', () => {
|
||||
const configuration = new Configuration(new ConfigurationModel(), new ConfigurationModel());
|
||||
const change = configuration.compareAndUpdateLocalUserConfiguration(toConfigurationModel({
|
||||
'launch': {
|
||||
'configuraiton': {}
|
||||
},
|
||||
'launch.version': 1,
|
||||
'tasks': {
|
||||
'version': 2
|
||||
}
|
||||
}));
|
||||
let testObject = new ConfigurationChangeEvent(change, undefined, configuration);
|
||||
|
||||
assert.deepEqual(testObject.affectedKeys, ['launch', 'launch.version', 'tasks']);
|
||||
assert.ok(testObject.affectsConfiguration('launch'));
|
||||
assert.ok(testObject.affectsConfiguration('launch.version'));
|
||||
assert.ok(testObject.affectsConfiguration('tasks'));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
suite('AllKeysConfigurationChangeEvent', () => {
|
||||
|
||||
test('changeEvent', () => {
|
||||
const configuration = new Configuration(new ConfigurationModel(), new ConfigurationModel());
|
||||
configuration.updateDefaultConfiguration(toConfigurationModel({
|
||||
'editor.lineNumbers': 'off',
|
||||
'[markdown]': {
|
||||
'editor.wordWrap': 'off'
|
||||
}
|
||||
}));
|
||||
configuration.updateLocalUserConfiguration(toConfigurationModel({
|
||||
'[json]': {
|
||||
'editor.lineNumbers': 'relative'
|
||||
}
|
||||
}));
|
||||
configuration.updateWorkspaceConfiguration(toConfigurationModel({ 'window.title': 'custom' }));
|
||||
configuration.updateFolderConfiguration(URI.file('file1'), toConfigurationModel({ 'window.zoomLevel': 2, 'window.restoreFullscreen': true }));
|
||||
configuration.updateFolderConfiguration(URI.file('file2'), toConfigurationModel({ 'workbench.editor.enablePreview': true, 'window.restoreWindows': true }));
|
||||
const workspace = new Workspace('a', [new WorkspaceFolder({ index: 0, name: 'a', uri: URI.file('file1') }), new WorkspaceFolder({ index: 1, name: 'b', uri: URI.file('file2') }), new WorkspaceFolder({ index: 2, name: 'c', uri: URI.file('folder3') })]);
|
||||
let testObject = new AllKeysConfigurationChangeEvent(configuration, workspace, ConfigurationTarget.USER, null);
|
||||
|
||||
assert.deepEqual(testObject.affectedKeys, ['editor.lineNumbers', '[markdown]', '[json]', 'window.title', 'window.zoomLevel', 'window.restoreFullscreen', 'workbench.editor.enablePreview', 'window.restoreWindows']);
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('window.title'));
|
||||
assert.ok(testObject.affectsConfiguration('window.title', { resource: URI.file('file1') }));
|
||||
assert.ok(testObject.affectsConfiguration('window.title', { resource: URI.file('file2') }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('window'));
|
||||
assert.ok(testObject.affectsConfiguration('window', { resource: URI.file('file1') }));
|
||||
assert.ok(testObject.affectsConfiguration('window', { resource: URI.file('file2') }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('window.zoomLevel'));
|
||||
assert.ok(testObject.affectsConfiguration('window.zoomLevel', { resource: URI.file('file1') }));
|
||||
assert.ok(!testObject.affectsConfiguration('window.zoomLevel', { resource: URI.file('file2') }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('window.restoreFullscreen'));
|
||||
assert.ok(testObject.affectsConfiguration('window.restoreFullscreen', { resource: URI.file('file1') }));
|
||||
assert.ok(!testObject.affectsConfiguration('window.restoreFullscreen', { resource: URI.file('file2') }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('window.restoreWindows'));
|
||||
assert.ok(testObject.affectsConfiguration('window.restoreWindows', { resource: URI.file('file2') }));
|
||||
assert.ok(!testObject.affectsConfiguration('window.restoreWindows', { resource: URI.file('file1') }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor.enablePreview'));
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor.enablePreview', { resource: URI.file('file2') }));
|
||||
assert.ok(!testObject.affectsConfiguration('workbench.editor.enablePreview', { resource: URI.file('file1') }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor'));
|
||||
assert.ok(testObject.affectsConfiguration('workbench.editor', { resource: URI.file('file2') }));
|
||||
assert.ok(!testObject.affectsConfiguration('workbench.editor', { resource: URI.file('file1') }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('workbench'));
|
||||
assert.ok(testObject.affectsConfiguration('workbench', { resource: URI.file('file2') }));
|
||||
assert.ok(!testObject.affectsConfiguration('workbench', { resource: URI.file('file1') }));
|
||||
|
||||
assert.ok(!testObject.affectsConfiguration('files'));
|
||||
assert.ok(!testObject.affectsConfiguration('files', { resource: URI.file('file1') }));
|
||||
assert.ok(!testObject.affectsConfiguration('files', { resource: URI.file('file2') }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('editor'));
|
||||
assert.ok(testObject.affectsConfiguration('editor', { resource: URI.file('file1') }));
|
||||
assert.ok(testObject.affectsConfiguration('editor', { resource: URI.file('file2') }));
|
||||
assert.ok(testObject.affectsConfiguration('editor', { resource: URI.file('file1'), overrideIdentifier: 'json' }));
|
||||
assert.ok(testObject.affectsConfiguration('editor', { resource: URI.file('file1'), overrideIdentifier: 'markdown' }));
|
||||
assert.ok(testObject.affectsConfiguration('editor', { resource: URI.file('file1'), overrideIdentifier: 'typescript' }));
|
||||
assert.ok(testObject.affectsConfiguration('editor', { resource: URI.file('file2'), overrideIdentifier: 'json' }));
|
||||
assert.ok(testObject.affectsConfiguration('editor', { resource: URI.file('file2'), overrideIdentifier: 'markdown' }));
|
||||
assert.ok(testObject.affectsConfiguration('editor', { resource: URI.file('file2'), overrideIdentifier: 'typescript' }));
|
||||
|
||||
assert.ok(testObject.affectsConfiguration('editor.lineNumbers'));
|
||||
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { resource: URI.file('file1') }));
|
||||
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { resource: URI.file('file2') }));
|
||||
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { resource: URI.file('file1'), overrideIdentifier: 'json' }));
|
||||
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { resource: URI.file('file1'), overrideIdentifier: 'markdown' }));
|
||||
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { resource: URI.file('file1'), overrideIdentifier: 'typescript' }));
|
||||
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { resource: URI.file('file2'), overrideIdentifier: 'json' }));
|
||||
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { resource: URI.file('file2'), overrideIdentifier: 'markdown' }));
|
||||
assert.ok(testObject.affectsConfiguration('editor.lineNumbers', { resource: URI.file('file2'), overrideIdentifier: 'typescript' }));
|
||||
|
||||
assert.ok(!testObject.affectsConfiguration('editor.wordWrap'));
|
||||
assert.ok(!testObject.affectsConfiguration('editor.wordWrap', { resource: URI.file('file1') }));
|
||||
assert.ok(!testObject.affectsConfiguration('editor.wordWrap', { resource: URI.file('file2') }));
|
||||
assert.ok(!testObject.affectsConfiguration('editor.wordWrap', { resource: URI.file('file1'), overrideIdentifier: 'json' }));
|
||||
assert.ok(!testObject.affectsConfiguration('editor.wordWrap', { resource: URI.file('file1'), overrideIdentifier: 'markdown' }));
|
||||
assert.ok(!testObject.affectsConfiguration('editor.wordWrap', { resource: URI.file('file1'), overrideIdentifier: 'typescript' }));
|
||||
assert.ok(!testObject.affectsConfiguration('editor.wordWrap', { resource: URI.file('file2'), overrideIdentifier: 'json' }));
|
||||
assert.ok(!testObject.affectsConfiguration('editor.wordWrap', { resource: URI.file('file2'), overrideIdentifier: 'markdown' }));
|
||||
assert.ok(!testObject.affectsConfiguration('editor.wordWrap', { resource: URI.file('file2'), overrideIdentifier: 'typescript' }));
|
||||
|
||||
assert.ok(!testObject.affectsConfiguration('editor.fontSize'));
|
||||
assert.ok(!testObject.affectsConfiguration('editor.fontSize', { resource: URI.file('file1') }));
|
||||
assert.ok(!testObject.affectsConfiguration('editor.fontSize', { resource: URI.file('file2') }));
|
||||
});
|
||||
});
|
||||
|
||||
function toConfigurationModel(obj: any): ConfigurationModel {
|
||||
const parser = new ConfigurationModelParser('test');
|
||||
parser.parseContent(JSON.stringify(obj));
|
||||
return parser.configurationModel;
|
||||
}
|
||||
|
||||
@@ -5,12 +5,18 @@
|
||||
|
||||
import { TernarySearchTree } from 'vs/base/common/map';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { getConfigurationKeys, IConfigurationOverrides, IConfigurationService, getConfigurationValue, isConfigurationOverrides } from 'vs/platform/configuration/common/configuration';
|
||||
import { getConfigurationKeys, IConfigurationOverrides, IConfigurationService, getConfigurationValue, isConfigurationOverrides, IConfigurationValue } from 'vs/platform/configuration/common/configuration';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
|
||||
export class TestConfigurationService implements IConfigurationService {
|
||||
public _serviceBrand: undefined;
|
||||
|
||||
private configuration = Object.create(null);
|
||||
private configuration: any;
|
||||
readonly onDidChangeConfiguration = new Emitter<any>().event;
|
||||
|
||||
constructor(configuration?: any) {
|
||||
this.configuration = configuration || Object.create(null);
|
||||
}
|
||||
|
||||
private configurationByRoot: TernarySearchTree<any> = TernarySearchTree.forPaths<any>();
|
||||
|
||||
@@ -33,7 +39,7 @@ export class TestConfigurationService implements IConfigurationService {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
public updateValue(key: string, overrides?: IConfigurationOverrides): Promise<void> {
|
||||
public updateValue(key: string, value: any): Promise<void> {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
@@ -49,27 +55,13 @@ export class TestConfigurationService implements IConfigurationService {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
public onDidChangeConfiguration() {
|
||||
return { dispose() { } };
|
||||
}
|
||||
|
||||
public inspect<T>(key: string, overrides?: IConfigurationOverrides): {
|
||||
default: T,
|
||||
user: T,
|
||||
userLocal?: T,
|
||||
userRemote?: T,
|
||||
workspace?: T,
|
||||
workspaceFolder?: T
|
||||
value: T,
|
||||
} {
|
||||
public inspect<T>(key: string, overrides?: IConfigurationOverrides): IConfigurationValue<T> {
|
||||
const config = this.getValue(undefined, overrides);
|
||||
|
||||
return {
|
||||
value: getConfigurationValue<T>(config, key),
|
||||
default: getConfigurationValue<T>(config, key),
|
||||
user: getConfigurationValue<T>(config, key),
|
||||
workspace: undefined,
|
||||
workspaceFolder: undefined
|
||||
user: getConfigurationValue<T>(config, key)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user