more 💄
This commit is contained in:
parent
92b2d10871
commit
f3ae32fc37
3 changed files with 36 additions and 41 deletions
|
@ -90,7 +90,7 @@ export function createApiFactory(
|
|||
const extHostCommands = col.define(ExtHostContext.ExtHostCommands).set<ExtHostCommands>(new ExtHostCommands(threadService, extHostHeapService));
|
||||
const extHostTreeViews = col.define(ExtHostContext.ExtHostTreeViews).set<ExtHostTreeViews>(new ExtHostTreeViews(threadService, extHostCommands));
|
||||
const extHostWorkspace = col.define(ExtHostContext.ExtHostWorkspace).set<ExtHostWorkspace>(new ExtHostWorkspace(threadService, initData.workspace));
|
||||
const extHostConfiguration = col.define(ExtHostContext.ExtHostConfiguration).set<ExtHostConfiguration>(new ExtHostConfiguration(threadService.get(MainContext.MainThreadConfiguration), initData.configuration, extHostWorkspace));
|
||||
const extHostConfiguration = col.define(ExtHostContext.ExtHostConfiguration).set<ExtHostConfiguration>(new ExtHostConfiguration(threadService.get(MainContext.MainThreadConfiguration), extHostWorkspace, initData.configuration));
|
||||
const extHostDiagnostics = col.define(ExtHostContext.ExtHostDiagnostics).set<ExtHostDiagnostics>(new ExtHostDiagnostics(threadService));
|
||||
const languageFeatures = col.define(ExtHostContext.ExtHostLanguageFeatures).set<ExtHostLanguageFeatures>(new ExtHostLanguageFeatures(threadService, extHostDocuments, extHostCommands, extHostHeapService, extHostDiagnostics));
|
||||
const extHostFileSystemEvent = col.define(ExtHostContext.ExtHostFileSystemEventService).set<ExtHostFileSystemEventService>(new ExtHostFileSystemEventService());
|
||||
|
|
|
@ -25,41 +25,32 @@ function lookUp(tree: any, key: string) {
|
|||
|
||||
export class ExtHostConfiguration extends ExtHostConfigurationShape {
|
||||
|
||||
private _onDidChangeConfiguration = new Emitter<void>();
|
||||
private _proxy: MainThreadConfigurationShape;
|
||||
private _data: IConfigurationData<any>;
|
||||
private _extHostWorkspace: ExtHostWorkspace;
|
||||
private readonly _onDidChangeConfiguration = new Emitter<void>();
|
||||
private readonly _proxy: MainThreadConfigurationShape;
|
||||
private readonly _extHostWorkspace: ExtHostWorkspace;
|
||||
private _configuration: Configuration<any>;
|
||||
|
||||
constructor(proxy: MainThreadConfigurationShape, data: IConfigurationData<any>, extWorkspace: ExtHostWorkspace) {
|
||||
constructor(proxy: MainThreadConfigurationShape, extHostWorkspace: ExtHostWorkspace, data: IConfigurationData<any>) {
|
||||
super();
|
||||
this._proxy = proxy;
|
||||
this._data = data;
|
||||
this._extHostWorkspace = extWorkspace;
|
||||
this._extHostWorkspace = extHostWorkspace;
|
||||
this._configuration = Configuration.parse(data, extHostWorkspace.workspace);
|
||||
}
|
||||
|
||||
get onDidChangeConfiguration(): Event<void> {
|
||||
return this._onDidChangeConfiguration && this._onDidChangeConfiguration.event;
|
||||
}
|
||||
|
||||
public $acceptConfigurationChanged(data: IConfigurationData<any>) {
|
||||
this._configuration = null;
|
||||
this._data = data;
|
||||
$acceptConfigurationChanged(data: IConfigurationData<any>) {
|
||||
this._configuration = Configuration.parse(data, this._extHostWorkspace.workspace);
|
||||
this._onDidChangeConfiguration.fire(undefined);
|
||||
}
|
||||
|
||||
private get configuration(): Configuration<any> {
|
||||
if (!this._configuration) {
|
||||
this._configuration = Configuration.parse(this._data, this._extHostWorkspace.workspace);
|
||||
}
|
||||
return this._configuration;
|
||||
}
|
||||
|
||||
public getConfiguration(section?: string): WorkspaceConfiguration {
|
||||
getConfiguration(section?: string): WorkspaceConfiguration {
|
||||
|
||||
const config = section
|
||||
? lookUp(this.configuration.getValue(), section)
|
||||
: this.configuration.getValue();
|
||||
? lookUp(this._configuration.getValue(), section)
|
||||
: this._configuration.getValue();
|
||||
|
||||
const result: WorkspaceConfiguration = {
|
||||
has(key: string): boolean {
|
||||
|
@ -83,7 +74,7 @@ export class ExtHostConfiguration extends ExtHostConfigurationShape {
|
|||
},
|
||||
inspect: <T>(key: string): { key: string; defaultValue?: T; globalValue?: T; workspaceValue?: T } => {
|
||||
key = section ? `${section}.${key}` : key;
|
||||
const config = this.configuration.values()[key];
|
||||
const config = this._configuration.values()[key];
|
||||
if (config) {
|
||||
return {
|
||||
key,
|
||||
|
|
|
@ -29,11 +29,11 @@ suite('ExtHostConfiguration', function () {
|
|||
if (!shape) {
|
||||
shape = new class extends MainThreadConfigurationShape { };
|
||||
}
|
||||
return new ExtHostConfiguration(shape, {
|
||||
return new ExtHostConfiguration(shape, new ExtHostWorkspace(new TestThreadService(), null), {
|
||||
defaults: new ConfigurationModel(contents),
|
||||
user: new ConfigurationModel(contents),
|
||||
folders: Object.create(null)
|
||||
}, new ExtHostWorkspace(new TestThreadService(), null));
|
||||
});
|
||||
}
|
||||
|
||||
test('getConfiguration fails regression test 1.7.1 -> 1.8 #15552', function () {
|
||||
|
@ -91,23 +91,27 @@ suite('ExtHostConfiguration', function () {
|
|||
'wordWrap': 'bounded'
|
||||
}
|
||||
}, ['editor.wordWrap']);
|
||||
const testObject = new ExtHostConfiguration(new class extends MainThreadConfigurationShape { }, {
|
||||
defaults: new ConfigurationModel({
|
||||
'editor': {
|
||||
'wordWrap': 'off'
|
||||
}
|
||||
}, ['editor.wordWrap']),
|
||||
user: new ConfigurationModel({
|
||||
'editor': {
|
||||
'wordWrap': 'on'
|
||||
}
|
||||
}, ['editor.wordWrap']),
|
||||
folders
|
||||
}, new ExtHostWorkspace(new TestThreadService(), {
|
||||
'id': 'foo',
|
||||
'roots': [URI.file('foo')],
|
||||
'name': 'foo'
|
||||
}));
|
||||
const testObject = new ExtHostConfiguration(
|
||||
new class extends MainThreadConfigurationShape { },
|
||||
new ExtHostWorkspace(new TestThreadService(), {
|
||||
'id': 'foo',
|
||||
'roots': [URI.file('foo')],
|
||||
'name': 'foo'
|
||||
}),
|
||||
{
|
||||
defaults: new ConfigurationModel({
|
||||
'editor': {
|
||||
'wordWrap': 'off'
|
||||
}
|
||||
}, ['editor.wordWrap']),
|
||||
user: new ConfigurationModel({
|
||||
'editor': {
|
||||
'wordWrap': 'on'
|
||||
}
|
||||
}, ['editor.wordWrap']),
|
||||
folders
|
||||
}
|
||||
);
|
||||
|
||||
const actual = testObject.getConfiguration().inspect('editor.wordWrap');
|
||||
assert.equal(actual.defaultValue, 'off');
|
||||
|
|
Loading…
Reference in a new issue