diff --git a/src/vs/platform/configuration/common/configurationService.ts b/src/vs/platform/configuration/common/configurationService.ts index 7f951687a8b27a3b44e5a38331d2ae76f9cf9a42..3020f09c25b757afd7e841808762723fc0732995 100644 --- a/src/vs/platform/configuration/common/configurationService.ts +++ b/src/vs/platform/configuration/common/configurationService.ts @@ -22,7 +22,6 @@ import {Registry} from 'vs/platform/platform'; import Event, {Emitter} from 'vs/base/common/event'; import {JSONPath} from 'vs/base/common/json'; - // ---- service abstract implementation export interface IStat { @@ -61,7 +60,6 @@ export abstract class ConfigurationService implements IConfigurationService, IDi private reloadConfigurationScheduler: RunOnceScheduler; constructor(contextService: IWorkspaceContextService, eventService: IEventService, workspaceSettingsRootFolder: string = '.vscode') { - this.contextService = contextService; this.eventService = eventService; @@ -229,7 +227,7 @@ export abstract class ConfigurationService implements IConfigurationService, IDi private handleFileEvents(event: FileChangesEvent): void { const events = event.changes; let affectedByChanges = false; - + for (let i = 0, len = events.length; i < len; i++) { const workspacePath = this.contextService.toWorkspaceRelativePath(events[i].resource); if (!workspacePath) { diff --git a/src/vs/workbench/services/configuration/node/configurationService.ts b/src/vs/workbench/services/configuration/node/configurationService.ts index d657781960ce0281277e15a8c1a85305df2f8b57..5ce1234b5bc194d6034b8fb96e1261e092b7bf29 100644 --- a/src/vs/workbench/services/configuration/node/configurationService.ts +++ b/src/vs/workbench/services/configuration/node/configurationService.ts @@ -27,10 +27,12 @@ export class ConfigurationService extends CommonConfigurationService { public _serviceBrand: any; - protected contextService: IWorkspaceContextService; private toDispose: IDisposable; - constructor(contextService: IWorkspaceContextService, eventService: IEventService) { + constructor( + contextService: IWorkspaceContextService, + eventService: IEventService + ) { super(contextService, eventService); this.registerListeners(); @@ -49,7 +51,7 @@ export class ConfigurationService extends CommonConfigurationService { } protected resolveContents(resources: uri[]): TPromise { - let contents: IContent[] = []; + const contents: IContent[] = []; return TPromise.join(resources.map((resource) => { return this.resolveContent(resource).then((content) => { @@ -118,12 +120,15 @@ export class ConfigurationService extends CommonConfigurationService { } public setUserConfiguration(key: any, value: any) : Thenable { - let appSettingsPath = this.contextService.getConfiguration().env.appSettingsPath; + const appSettingsPath = this.contextService.getConfiguration().env.appSettingsPath; + return readFile(appSettingsPath, 'utf8').then(content => { - let {tabSize, insertSpaces} = this.getConfiguration<{ tabSize: number; insertSpaces: boolean }>('editor'); - let path: JSONPath = typeof key === 'string' ? ( key).split('.') : key; - let edits = setProperty(content, path, value, {insertSpaces, tabSize, eol: '\n'}); + const {tabSize, insertSpaces} = this.getConfiguration<{ tabSize: number; insertSpaces: boolean }>('editor'); + const path: JSONPath = typeof key === 'string' ? ( key).split('.') : key; + const edits = setProperty(content, path, value, {insertSpaces, tabSize, eol: '\n'}); + content = applyEdits(content, edits); + return writeFile(appSettingsPath, content, 'utf8'); }); }