diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index b5a071701a6b201078ab3b32b409e808fd2b7042..d39add02215b632e63bedbeda4f49af159c527e7 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -102,7 +102,7 @@ export class ExtHostAPIImplementation { const extHostDocuments = col.define(ExtHostContext.ExtHostDocuments).set(new ExtHostDocuments(threadService)); const extHostEditors = col.define(ExtHostContext.ExtHostEditors).set(new ExtHostEditors(threadService, extHostDocuments)); const extHostCommands = col.define(ExtHostContext.ExtHostCommands).set(new ExtHostCommands(threadService, extHostEditors)); - const extHostConfiguration = col.define(ExtHostContext.ExtHostConfiguration).set(new ExtHostConfiguration()); + const extHostConfiguration = col.define(ExtHostContext.ExtHostConfiguration).set(new ExtHostConfiguration(threadService)); const extHostDiagnostics = col.define(ExtHostContext.ExtHostDiagnostics).set(new ExtHostDiagnostics(threadService)); const languageFeatures = col.define(ExtHostContext.ExtHostLanguageFeatures).set(new ExtHostLanguageFeatures(threadService, extHostDocuments, extHostCommands, extHostDiagnostics)); const extHostFileSystemEvent = col.define(ExtHostContext.ExtHostFileSystemEventService).set(new ExtHostFileSystemEventService()); diff --git a/src/vs/workbench/api/node/extHost.contribution.ts b/src/vs/workbench/api/node/extHost.contribution.ts index bb86e048df38736cfda689f1ef875b5546804948..1399802772f2e3273d8e3b8075f8a00a00a9005a 100644 --- a/src/vs/workbench/api/node/extHost.contribution.ts +++ b/src/vs/workbench/api/node/extHost.contribution.ts @@ -61,6 +61,7 @@ export class ExtHostContribution implements IWorkbenchContribution { // Addressable instances const col = new InstanceCollection(); col.define(MainContext.MainThreadCommands).set(create(MainThreadCommands)); + col.define(MainContext.MainThreadConfiguration).set(create(MainThreadConfiguration)); col.define(MainContext.MainThreadDiagnostics).set(create(MainThreadDiagnostics)); col.define(MainContext.MainThreadDocuments).set(create(MainThreadDocuments)); col.define(MainContext.MainThreadEditors).set(create(MainThreadEditors)); diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index a7ed16ce7eb8d4724a33ab1805fe87c059f36e09..b93eced9b757d5df9f0e3587e6edfa1d9861c98a 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -27,6 +27,8 @@ import * as editorCommon from 'vs/editor/common/editorCommon'; import * as modes from 'vs/editor/common/modes'; import {IResourceEdit} from 'vs/editor/common/services/bulkEdit'; +import {ConfigurationTarget, ConfigurationEditingResult} from 'vs/workbench/services/configuration/common/configurationEditing'; + import {IPickOpenEntry, IPickOptions} from 'vs/workbench/services/quickopen/common/quickOpenService'; import {IWorkspaceSymbol} from 'vs/workbench/parts/search/common/search'; import {TextEditorRevealType, ITextEditorConfigurationUpdate, IResolvedTextEditorConfiguration, ISelectionChangeEvent} from './mainThreadEditorsTracker'; @@ -81,6 +83,10 @@ export abstract class MainThreadCommandsShape { $getCommands(): Thenable { throw ni(); } } +export abstract class MainThreadConfigurationShape { + $updateConfigurationOption(target: ConfigurationTarget, key: string, value: any): TPromise { throw ni(); } +} + export abstract class MainThreadDiagnosticsShape { $changeMany(owner: string, entries: [URI, IMarkerData[]][]): TPromise { throw ni(); } $clear(owner: string): TPromise { throw ni(); } @@ -290,6 +296,7 @@ export abstract class ExtHostQuickOpenShape { export const MainContext = { MainThreadCommands: createMainId('MainThreadCommands', MainThreadCommandsShape), + MainThreadConfiguration: createMainId('MainThreadConfiguration', MainThreadConfigurationShape), MainThreadDiagnostics: createMainId('MainThreadDiagnostics', MainThreadDiagnosticsShape), MainThreadDocuments: createMainId('MainThreadDocuments', MainThreadDocumentsShape), MainThreadEditors: createMainId('MainThreadEditors', MainThreadEditorsShape), diff --git a/src/vs/workbench/api/node/extHostConfiguration.ts b/src/vs/workbench/api/node/extHostConfiguration.ts index b37ec21751b8496ee8cb73fc2e9c6ec17f64f797..6bf43202bf4a0ef0e935a950faa821ce494a29a1 100644 --- a/src/vs/workbench/api/node/extHostConfiguration.ts +++ b/src/vs/workbench/api/node/extHostConfiguration.ts @@ -8,16 +8,19 @@ import {clone} from 'vs/base/common/objects'; import {illegalState} from 'vs/base/common/errors'; import Event, {Emitter} from 'vs/base/common/event'; import {WorkspaceConfiguration} from 'vscode'; -import {ExtHostConfigurationShape} from './extHost.protocol'; +import {ExtHostConfigurationShape, MainContext, MainThreadConfigurationShape} from './extHost.protocol'; +import {IThreadService} from 'vs/workbench/services/thread/common/threadService'; export class ExtHostConfiguration extends ExtHostConfigurationShape { - private _config: any; + private _proxy: MainThreadConfigurationShape; private _hasConfig: boolean; + private _config: any; private _onDidChangeConfiguration: Emitter; - constructor() { + constructor(threadService: IThreadService) { super(); + this._proxy = threadService.get(MainContext.MainThreadConfiguration); this._onDidChangeConfiguration = new Emitter(); } diff --git a/src/vs/workbench/api/node/mainThreadConfiguration.ts b/src/vs/workbench/api/node/mainThreadConfiguration.ts index 89e9d0ca86f2825d4920d5a20e780aa498a748bf..deab01bda601db3129edb6e8f7f26b659b74bb1f 100644 --- a/src/vs/workbench/api/node/mainThreadConfiguration.ts +++ b/src/vs/workbench/api/node/mainThreadConfiguration.ts @@ -4,29 +4,35 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; +import {TPromise} from 'vs/base/common/winjs.base'; import {IDisposable, dispose} from 'vs/base/common/lifecycle'; import {IThreadService} from 'vs/workbench/services/thread/common/threadService'; import {IWorkbenchConfigurationService} from 'vs/workbench/services/configuration/common/configuration'; -import {ExtHostContext, ExtHostConfigurationShape} from './extHost.protocol'; +import {IConfigurationEditingService, ConfigurationTarget, ConfigurationEditingResult} from 'vs/workbench/services/configuration/common/configurationEditing'; +import {MainThreadConfigurationShape, ExtHostContext} from './extHost.protocol'; -export class MainThreadConfiguration { +export class MainThreadConfiguration extends MainThreadConfigurationShape { - private _configurationService: IWorkbenchConfigurationService; + private _configurationEditingService: IConfigurationEditingService; private _toDispose: IDisposable; - private _proxy: ExtHostConfigurationShape; constructor( + @IConfigurationEditingService configurationEditingService: IConfigurationEditingService, @IWorkbenchConfigurationService configurationService: IWorkbenchConfigurationService, @IThreadService threadService: IThreadService ) { - this._configurationService = configurationService; - this._proxy = threadService.get(ExtHostContext.ExtHostConfiguration); - - this._toDispose = this._configurationService.onDidUpdateConfiguration(event => this._proxy.$acceptConfigurationChanged(event.config)); - this._proxy.$acceptConfigurationChanged(this._configurationService.getConfiguration()); + super(); + this._configurationEditingService = configurationEditingService; + const proxy = threadService.get(ExtHostContext.ExtHostConfiguration); + this._toDispose = configurationService.onDidUpdateConfiguration(event => proxy.$acceptConfigurationChanged(event.config)); + proxy.$acceptConfigurationChanged(configurationService.getConfiguration()); } public dispose(): void { this._toDispose = dispose(this._toDispose); } + + $updateConfigurationOption(target: ConfigurationTarget, key: string, value: any): TPromise { + return this._configurationEditingService.writeConfiguration(target, [{ key, value }]); + } }