Skip to content

Commit b2463e4

Browse files
committed
1 parent 0b81395 commit b2463e4

4 files changed

Lines changed: 86 additions & 9 deletions

File tree

src/vs/platform/configuration/common/configurationModels.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export class ConfigurationModel implements IConfigurationModel {
8989
contents[key] = contentsForKey;
9090
}
9191

92-
return new ConfigurationModel(contents);
92+
return new ConfigurationModel(contents, this.keys, this.overrides);
9393
}
9494

9595
merge(...others: ConfigurationModel[]): ConfigurationModel {

src/vs/vscode.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4360,7 +4360,7 @@ declare module 'vscode' {
43604360
workspaceFolderValue?: T,
43614361

43624362
defaultLanguageValue?: T;
4363-
userLanguageValue?: T;
4363+
globalLanguageValue?: T;
43644364
workspaceLanguageValue?: T;
43654365
workspaceFolderLanguageValue?: T;
43664366

src/vs/workbench/api/common/extHostConfiguration.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ type ConfigurationInspect<T> = {
4242
workspaceFolderValue?: T,
4343

4444
defaultLanguageValue?: T;
45-
userLanguageValue?: T;
45+
globalLanguageValue?: T;
4646
workspaceLanguageValue?: T;
4747
workspaceFolderLanguageValue?: T;
4848

@@ -260,13 +260,13 @@ export class ExtHostConfigProvider {
260260
return {
261261
key,
262262

263-
defaultValue: config.defaultValue,
264-
globalValue: config.userValue,
265-
workspaceValue: config.workspaceValue,
266-
workspaceFolderValue: config.workspaceFolderValue,
263+
defaultValue: config.default?.value,
264+
globalValue: config.user?.value,
265+
workspaceValue: config.workspace?.value,
266+
workspaceFolderValue: config.workspaceFolder?.value,
267267

268268
defaultLanguageValue: config.default?.override,
269-
userLanguageValue: config.user?.override,
269+
globalLanguageValue: config.user?.override,
270270
workspaceLanguageValue: config.workspace?.override,
271271
workspaceFolderLanguageValue: config.workspaceFolder?.override,
272272

src/vs/workbench/test/electron-browser/api/extHostConfiguration.test.ts

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { URI, UriComponents } from 'vs/base/common/uri';
88
import { ExtHostWorkspace } from 'vs/workbench/api/common/extHostWorkspace';
99
import { ExtHostConfigProvider } from 'vs/workbench/api/common/extHostConfiguration';
1010
import { MainThreadConfigurationShape, IConfigurationInitData } from 'vs/workbench/api/common/extHost.protocol';
11-
import { ConfigurationModel } from 'vs/platform/configuration/common/configurationModels';
11+
import { ConfigurationModel, ConfigurationModelParser } from 'vs/platform/configuration/common/configurationModels';
1212
import { TestRPCProtocol } from './testRPCProtocol';
1313
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
1414
import { IWorkspaceFolder, WorkspaceFolder } from 'vs/platform/workspace/common/workspace';
@@ -476,6 +476,76 @@ suite('ExtHostConfiguration', function () {
476476
assert.equal(actual2.workspaceFolderValue, undefined);
477477
});
478478

479+
test('inspect with language overrides', function () {
480+
const firstRoot = URI.file('foo1');
481+
const secondRoot = URI.file('foo2');
482+
const folders: [UriComponents, IConfigurationModel][] = [];
483+
folders.push([firstRoot, toConfigurationModel({
484+
'editor.wordWrap': 'bounded',
485+
'[typescript]': {
486+
'editor.wordWrap': 'unbounded',
487+
}
488+
})]);
489+
folders.push([secondRoot, toConfigurationModel({})]);
490+
491+
const extHostWorkspace = createExtHostWorkspace();
492+
extHostWorkspace.$initializeWorkspace({
493+
'id': 'foo',
494+
'folders': [aWorkspaceFolder(firstRoot, 0), aWorkspaceFolder(secondRoot, 1)],
495+
'name': 'foo'
496+
});
497+
const testObject = new ExtHostConfigProvider(
498+
new class extends mock<MainThreadConfigurationShape>() { },
499+
extHostWorkspace,
500+
{
501+
defaults: toConfigurationModel({
502+
'editor.wordWrap': 'off',
503+
'[markdown]': {
504+
'editor.wordWrap': 'bounded',
505+
}
506+
}),
507+
user: toConfigurationModel({
508+
'editor.wordWrap': 'bounded',
509+
'[typescript]': {
510+
'editor.lineNumbers': 'off',
511+
}
512+
}),
513+
workspace: toConfigurationModel({
514+
'[typescript]': {
515+
'editor.wordWrap': 'unbounded',
516+
'editor.lineNumbers': 'off',
517+
}
518+
}),
519+
folders,
520+
configurationScopes: []
521+
},
522+
new NullLogService()
523+
);
524+
525+
let actual = testObject.getConfiguration(undefined, { uri: firstRoot, languageId: 'typescript' }).inspect('editor.wordWrap')!;
526+
assert.equal(actual.defaultValue, 'off');
527+
assert.equal(actual.globalValue, 'bounded');
528+
assert.equal(actual.workspaceValue, undefined);
529+
assert.equal(actual.workspaceFolderValue, 'bounded');
530+
assert.equal(actual.defaultLanguageValue, undefined);
531+
assert.equal(actual.globalLanguageValue, undefined);
532+
assert.equal(actual.workspaceLanguageValue, 'unbounded');
533+
assert.equal(actual.workspaceFolderLanguageValue, 'unbounded');
534+
assert.deepEqual(actual.languageIds, ['markdown', 'typescript']);
535+
536+
actual = testObject.getConfiguration(undefined, { uri: secondRoot, languageId: 'typescript' }).inspect('editor.wordWrap')!;
537+
assert.equal(actual.defaultValue, 'off');
538+
assert.equal(actual.globalValue, 'bounded');
539+
assert.equal(actual.workspaceValue, undefined);
540+
assert.equal(actual.workspaceFolderValue, undefined);
541+
assert.equal(actual.defaultLanguageValue, undefined);
542+
assert.equal(actual.globalLanguageValue, undefined);
543+
assert.equal(actual.workspaceLanguageValue, 'unbounded');
544+
assert.equal(actual.workspaceFolderLanguageValue, undefined);
545+
assert.deepEqual(actual.languageIds, ['markdown', 'typescript']);
546+
});
547+
548+
479549
test('getConfiguration vs get', function () {
480550

481551
const all = createExtHostConfiguration({
@@ -654,4 +724,11 @@ suite('ExtHostConfiguration', function () {
654724
function aWorkspaceFolder(uri: URI, index: number, name: string = ''): IWorkspaceFolder {
655725
return new WorkspaceFolder({ uri, name, index });
656726
}
727+
728+
function toConfigurationModel(obj: any): ConfigurationModel {
729+
const parser = new ConfigurationModelParser('test');
730+
parser.parseContent(JSON.stringify(obj));
731+
return parser.configurationModel;
732+
}
733+
657734
});

0 commit comments

Comments
 (0)