polish code
This commit is contained in:
parent
817c5c2d6f
commit
01a25e9455
|
@ -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) {
|
||||
|
|
|
@ -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<IContent[]> {
|
||||
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<void> {
|
||||
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' ? (<string> key).split('.') : <JSONPath> 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' ? (<string> key).split('.') : <JSONPath> key;
|
||||
const edits = setProperty(content, path, value, {insertSpaces, tabSize, eol: '\n'});
|
||||
|
||||
content = applyEdits(content, edits);
|
||||
|
||||
return writeFile(appSettingsPath, content, 'utf8');
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue