提交 0ae05b9f 编写于 作者: S Sandeep Somavarapu

Fix #21159

上级 77d8b438
......@@ -48,7 +48,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
_serviceBrand: any;
// TODO:@sandy merge these models into editor inputs by extending resource editor model
private defaultPreferencesEditorModels: Map<URI, IPreferencesEditorModel<any>>;
private defaultPreferencesEditorModels: Map<URI, TPromise<IPreferencesEditorModel<any>>>;
private lastOpenedSettingsInput: PreferencesEditorInput = null;
constructor(
......@@ -68,7 +68,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
@IExtensionService private extensionService: IExtensionService
) {
super();
this.defaultPreferencesEditorModels = new Map<URI, IPreferencesEditorModel<any>>();
this.defaultPreferencesEditorModels = new Map<URI, TPromise<IPreferencesEditorModel<any>>>();
this.editorGroupService.onEditorsChanged(() => {
const activeEditorInput = this.editorService.getActiveEditorInput();
if (activeEditorInput instanceof PreferencesEditorInput) {
......@@ -89,34 +89,36 @@ export class PreferencesService extends Disposable implements IPreferencesServic
}
createDefaultPreferencesEditorModel(uri: URI): TPromise<IPreferencesEditorModel<any>> {
const editorModel = this.defaultPreferencesEditorModels.get(uri);
if (editorModel) {
return TPromise.as(editorModel);
let promise = this.defaultPreferencesEditorModels.get(uri);
if (promise) {
return promise;
}
if (this.defaultSettingsResource.fsPath === uri.fsPath) {
return TPromise.join<any>([this.extensionService.onReady(), this.fetchMostCommonlyUsedSettings()])
promise = TPromise.join<any>([this.extensionService.onReady(), this.fetchMostCommonlyUsedSettings()])
.then(result => {
const mostCommonSettings = result[1];
const model = this.instantiationService.createInstance(DefaultSettingsEditorModel, uri, mostCommonSettings);
this.defaultPreferencesEditorModels.set(uri, model);
return model;
});
this.defaultPreferencesEditorModels.set(uri, promise);
return promise;
}
if (this.defaultKeybindingsResource.fsPath === uri.fsPath) {
const model = this.instantiationService.createInstance(DefaultKeybindingsEditorModel, uri);
this.defaultPreferencesEditorModels.set(uri, model);
return TPromise.wrap(model);
promise = TPromise.wrap(model);
this.defaultPreferencesEditorModels.set(uri, promise);
return promise;
}
return null;
}
public resolvePreferencesEditorModel(uri: URI): TPromise<IPreferencesEditorModel<any>> {
const model = this.defaultPreferencesEditorModels.get(uri);
if (model) {
return TPromise.wrap(model);
const promise = this.defaultPreferencesEditorModels.get(uri);
if (promise) {
return promise;
}
if (this.getEditableSettingsURI(ConfigurationTarget.USER).fsPath === uri.fsPath) {
......
......@@ -450,7 +450,7 @@ export class DefaultSettingsEditorModel extends AbstractSettingsModel implements
}
private parse() {
const configurations = Registry.as<IConfigurationRegistry>(Extensions.Configuration).getConfigurations();
const configurations = Registry.as<IConfigurationRegistry>(Extensions.Configuration).getConfigurations().slice();
const settingsGroups = configurations.sort(this.compareConfigurationNodes).reduce((result, config, index, array) => this.parseConfig(config, result, array), []);
const mostCommonlyUsed = this.getMostCommonlyUsedSettings(settingsGroups);
this._allSettingsGroups = [mostCommonlyUsed, ...settingsGroups];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册