提交 83660da7 编写于 作者: R Rob Lourens

Replace TPromise in settings #53526

上级 ca6e101a
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
import { Action } from 'vs/base/common/actions'; import { Action } from 'vs/base/common/actions';
import { dispose, IDisposable } from 'vs/base/common/lifecycle'; import { dispose, IDisposable } from 'vs/base/common/lifecycle';
import { URI } from 'vs/base/common/uri'; import { URI } from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base';
import { IModelService } from 'vs/editor/common/services/modelService'; import { IModelService } from 'vs/editor/common/services/modelService';
import { IModeService } from 'vs/editor/common/services/modeService'; import { IModeService } from 'vs/editor/common/services/modeService';
import * as nls from 'vs/nls'; import * as nls from 'vs/nls';
...@@ -30,7 +29,7 @@ export class OpenRawDefaultSettingsAction extends Action { ...@@ -30,7 +29,7 @@ export class OpenRawDefaultSettingsAction extends Action {
super(id, label); super(id, label);
} }
public run(event?: any): TPromise<any> { public run(event?: any): Thenable<any> {
return this.preferencesService.openRawDefaultSettings(); return this.preferencesService.openRawDefaultSettings();
} }
} }
...@@ -48,7 +47,7 @@ export class OpenSettings2Action extends Action { ...@@ -48,7 +47,7 @@ export class OpenSettings2Action extends Action {
super(id, label); super(id, label);
} }
public run(event?: any): TPromise<any> { public run(event?: any): Thenable<any> {
return this.preferencesService.openSettings(false); return this.preferencesService.openSettings(false);
} }
} }
...@@ -66,7 +65,7 @@ export class OpenSettingsAction extends Action { ...@@ -66,7 +65,7 @@ export class OpenSettingsAction extends Action {
super(id, label); super(id, label);
} }
public run(event?: any): TPromise<any> { public run(event?: any): Thenable<any> {
return this.preferencesService.openSettings(); return this.preferencesService.openSettings();
} }
} }
...@@ -84,7 +83,7 @@ export class OpenSettingsJsonAction extends Action { ...@@ -84,7 +83,7 @@ export class OpenSettingsJsonAction extends Action {
super(id, label); super(id, label);
} }
public run(event?: any): TPromise<any> { public run(event?: any): Thenable<any> {
return this.preferencesService.openSettings(true); return this.preferencesService.openSettings(true);
} }
} }
...@@ -102,7 +101,7 @@ export class OpenGlobalSettingsAction extends Action { ...@@ -102,7 +101,7 @@ export class OpenGlobalSettingsAction extends Action {
super(id, label); super(id, label);
} }
public run(event?: any): TPromise<any> { public run(event?: any): Thenable<any> {
return this.preferencesService.openGlobalSettings(); return this.preferencesService.openGlobalSettings();
} }
} }
...@@ -120,7 +119,7 @@ export class OpenGlobalKeybindingsAction extends Action { ...@@ -120,7 +119,7 @@ export class OpenGlobalKeybindingsAction extends Action {
super(id, label); super(id, label);
} }
public run(event?: any): TPromise<any> { public run(event?: any): Thenable<any> {
return this.preferencesService.openGlobalKeybindingSettings(false); return this.preferencesService.openGlobalKeybindingSettings(false);
} }
} }
...@@ -138,7 +137,7 @@ export class OpenGlobalKeybindingsFileAction extends Action { ...@@ -138,7 +137,7 @@ export class OpenGlobalKeybindingsFileAction extends Action {
super(id, label); super(id, label);
} }
public run(event?: any): TPromise<any> { public run(event?: any): Thenable<any> {
return this.preferencesService.openGlobalKeybindingSettings(true); return this.preferencesService.openGlobalKeybindingSettings(true);
} }
} }
...@@ -156,7 +155,7 @@ export class OpenDefaultKeybindingsFileAction extends Action { ...@@ -156,7 +155,7 @@ export class OpenDefaultKeybindingsFileAction extends Action {
super(id, label); super(id, label);
} }
public run(event?: any): TPromise<any> { public run(event?: any): Thenable<any> {
return this.preferencesService.openDefaultKeybindingsFile(); return this.preferencesService.openDefaultKeybindingsFile();
} }
} }
...@@ -183,7 +182,7 @@ export class OpenWorkspaceSettingsAction extends Action { ...@@ -183,7 +182,7 @@ export class OpenWorkspaceSettingsAction extends Action {
this.enabled = this.workspaceContextService.getWorkbenchState() !== WorkbenchState.EMPTY; this.enabled = this.workspaceContextService.getWorkbenchState() !== WorkbenchState.EMPTY;
} }
public run(event?: any): TPromise<any> { public run(event?: any): Thenable<any> {
return this.preferencesService.openWorkspaceSettings(); return this.preferencesService.openWorkspaceSettings();
} }
...@@ -220,7 +219,7 @@ export class OpenFolderSettingsAction extends Action { ...@@ -220,7 +219,7 @@ export class OpenFolderSettingsAction extends Action {
this.enabled = this.workspaceContextService.getWorkbenchState() === WorkbenchState.WORKSPACE && this.workspaceContextService.getWorkspace().folders.length > 0; this.enabled = this.workspaceContextService.getWorkbenchState() === WorkbenchState.WORKSPACE && this.workspaceContextService.getWorkspace().folders.length > 0;
} }
public run(): TPromise<any> { public run(): Thenable<any> {
return this.commandService.executeCommand<IWorkspaceFolder>(PICK_WORKSPACE_FOLDER_COMMAND_ID) return this.commandService.executeCommand<IWorkspaceFolder>(PICK_WORKSPACE_FOLDER_COMMAND_ID)
.then(workspaceFolder => { .then(workspaceFolder => {
if (workspaceFolder) { if (workspaceFolder) {
...@@ -253,7 +252,7 @@ export class ConfigureLanguageBasedSettingsAction extends Action { ...@@ -253,7 +252,7 @@ export class ConfigureLanguageBasedSettingsAction extends Action {
super(id, label); super(id, label);
} }
public run(): TPromise<any> { public run(): Thenable<any> {
const languages = this.modeService.getRegisteredLanguageNames(); const languages = this.modeService.getRegisteredLanguageNames();
const picks: IQuickPickItem[] = languages.sort().map((lang, index) => { const picks: IQuickPickItem[] = languages.sort().map((lang, index) => {
let description: string = nls.localize('languageDescriptionConfigured', "({0})", this.modeService.getModeIdForLanguageName(lang.toLowerCase())); let description: string = nls.localize('languageDescriptionConfigured', "({0})", this.modeService.getModeIdForLanguageName(lang.toLowerCase()));
......
...@@ -16,7 +16,6 @@ import { ArrayNavigator } from 'vs/base/common/iterator'; ...@@ -16,7 +16,6 @@ import { ArrayNavigator } from 'vs/base/common/iterator';
import { Disposable, dispose, IDisposable } from 'vs/base/common/lifecycle'; import { Disposable, dispose, IDisposable } from 'vs/base/common/lifecycle';
import * as strings from 'vs/base/common/strings'; import * as strings from 'vs/base/common/strings';
import { URI } from 'vs/base/common/uri'; import { URI } from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { EditorExtensionsRegistry, IEditorContributionCtor, registerEditorContribution } from 'vs/editor/browser/editorExtensions'; import { EditorExtensionsRegistry, IEditorContributionCtor, registerEditorContribution } from 'vs/editor/browser/editorExtensions';
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget'; import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
...@@ -204,7 +203,7 @@ export class PreferencesEditor extends BaseEditor { ...@@ -204,7 +203,7 @@ export class PreferencesEditor extends BaseEditor {
super.setEditorVisible(visible, group); super.setEditorVisible(visible, group);
} }
private updateInput(newInput: PreferencesEditorInput, options: EditorOptions, token: CancellationToken): TPromise<void> { private updateInput(newInput: PreferencesEditorInput, options: EditorOptions, token: CancellationToken): Promise<void> {
return this.sideBySidePreferencesWidget.setInput(<DefaultPreferencesEditorInput>newInput.details, <EditorInput>newInput.master, options, token).then(({ defaultPreferencesRenderer, editablePreferencesRenderer }) => { return this.sideBySidePreferencesWidget.setInput(<DefaultPreferencesEditorInput>newInput.details, <EditorInput>newInput.master, options, token).then(({ defaultPreferencesRenderer, editablePreferencesRenderer }) => {
if (token.isCancellationRequested) { if (token.isCancellationRequested) {
return void 0; return void 0;
...@@ -230,12 +229,12 @@ export class PreferencesEditor extends BaseEditor { ...@@ -230,12 +229,12 @@ export class PreferencesEditor extends BaseEditor {
}); });
} }
private triggerSearch(query: string): TPromise<void> { private triggerSearch(query: string): Promise<void> {
if (query) { if (query) {
return TPromise.join([ return Promise.all([
this.localSearchDelayer.trigger(() => this.preferencesRenderers.localFilterPreferences(query).then(() => { })), this.localSearchDelayer.trigger(() => this.preferencesRenderers.localFilterPreferences(query).then(() => { })),
this.remoteSearchThrottle.trigger(() => TPromise.wrap(this.progressService.showWhile(this.preferencesRenderers.remoteSearchPreferences(query), 500))) this.remoteSearchThrottle.trigger(() => Promise.resolve(this.progressService.showWhile(this.preferencesRenderers.remoteSearchPreferences(query), 500)))
]) as TPromise; ]).then(() => { });
} else { } else {
// When clearing the input, update immediately to clear it // When clearing the input, update immediately to clear it
this.localSearchDelayer.cancel(); this.localSearchDelayer.cancel();
...@@ -251,8 +250,8 @@ export class PreferencesEditor extends BaseEditor { ...@@ -251,8 +250,8 @@ export class PreferencesEditor extends BaseEditor {
if (this.editorService.activeControl !== this) { if (this.editorService.activeControl !== this) {
this.focus(); this.focus();
} }
const promise = this.input && this.input.isDirty() ? this.input.save() : TPromise.as(true); const promise: Thenable<boolean> = this.input && this.input.isDirty() ? this.input.save() : Promise.resolve(true);
promise.then(value => { promise.then(() => {
if (target === ConfigurationTarget.USER) { if (target === ConfigurationTarget.USER) {
this.preferencesService.switchSettings(ConfigurationTarget.USER, this.preferencesService.userSettingsResource, true); this.preferencesService.switchSettings(ConfigurationTarget.USER, this.preferencesService.userSettingsResource, true);
} else if (target === ConfigurationTarget.WORKSPACE) { } else if (target === ConfigurationTarget.WORKSPACE) {
...@@ -438,7 +437,7 @@ class PreferencesRenderersController extends Disposable { ...@@ -438,7 +437,7 @@ class PreferencesRenderersController extends Disposable {
this._prefsModelsForSearch = new Map<string, ISettingsEditorModel>(); this._prefsModelsForSearch = new Map<string, ISettingsEditorModel>();
} }
remoteSearchPreferences(query: string, updateCurrentResults?: boolean): TPromise<void> { remoteSearchPreferences(query: string, updateCurrentResults?: boolean): Promise<void> {
if (this.lastFilterResult && this.lastFilterResult.exactMatch) { if (this.lastFilterResult && this.lastFilterResult.exactMatch) {
// Skip and clear remote search // Skip and clear remote search
query = ''; query = '';
...@@ -467,7 +466,7 @@ class PreferencesRenderersController extends Disposable { ...@@ -467,7 +466,7 @@ class PreferencesRenderersController extends Disposable {
}); });
} }
localFilterPreferences(query: string, updateCurrentResults?: boolean): TPromise<boolean> { localFilterPreferences(query: string, updateCurrentResults?: boolean): Promise<boolean> {
if (this._settingsNavigator) { if (this._settingsNavigator) {
this._settingsNavigator.reset(); this._settingsNavigator.reset();
} }
...@@ -476,10 +475,10 @@ class PreferencesRenderersController extends Disposable { ...@@ -476,10 +475,10 @@ class PreferencesRenderersController extends Disposable {
return this.filterOrSearchPreferences(query, this._currentLocalSearchProvider, 'filterResult', nls.localize('filterResult', "Filtered Results"), 0, undefined, updateCurrentResults); return this.filterOrSearchPreferences(query, this._currentLocalSearchProvider, 'filterResult', nls.localize('filterResult', "Filtered Results"), 0, undefined, updateCurrentResults);
} }
private filterOrSearchPreferences(query: string, searchProvider: ISearchProvider, groupId: string, groupLabel: string, groupOrder: number, token?: CancellationToken, editableContentOnly?: boolean): TPromise<boolean> { private filterOrSearchPreferences(query: string, searchProvider: ISearchProvider, groupId: string, groupLabel: string, groupOrder: number, token?: CancellationToken, editableContentOnly?: boolean): Promise<boolean> {
this._lastQuery = query; this._lastQuery = query;
const filterPs: TPromise<IFilterResult>[] = [this._filterOrSearchPreferences(query, this.editablePreferencesRenderer, searchProvider, groupId, groupLabel, groupOrder, token)]; const filterPs: Promise<IFilterResult>[] = [this._filterOrSearchPreferences(query, this.editablePreferencesRenderer, searchProvider, groupId, groupLabel, groupOrder, token)];
if (!editableContentOnly) { if (!editableContentOnly) {
filterPs.push( filterPs.push(
this._filterOrSearchPreferences(query, this.defaultPreferencesRenderer, searchProvider, groupId, groupLabel, groupOrder, token)); this._filterOrSearchPreferences(query, this.defaultPreferencesRenderer, searchProvider, groupId, groupLabel, groupOrder, token));
...@@ -487,7 +486,7 @@ class PreferencesRenderersController extends Disposable { ...@@ -487,7 +486,7 @@ class PreferencesRenderersController extends Disposable {
this.searchAllSettingsTargets(query, searchProvider, groupId, groupLabel, groupOrder, token).then(() => null)); this.searchAllSettingsTargets(query, searchProvider, groupId, groupLabel, groupOrder, token).then(() => null));
} }
return TPromise.join(filterPs).then(results => { return Promise.all(filterPs).then(results => {
let [editableFilterResult, defaultFilterResult] = results; let [editableFilterResult, defaultFilterResult] = results;
if (!defaultFilterResult && editableContentOnly) { if (!defaultFilterResult && editableContentOnly) {
...@@ -501,7 +500,7 @@ class PreferencesRenderersController extends Disposable { ...@@ -501,7 +500,7 @@ class PreferencesRenderersController extends Disposable {
}); });
} }
private searchAllSettingsTargets(query: string, searchProvider: ISearchProvider, groupId: string, groupLabel: string, groupOrder: number, token?: CancellationToken): TPromise<void> { private searchAllSettingsTargets(query: string, searchProvider: ISearchProvider, groupId: string, groupLabel: string, groupOrder: number, token?: CancellationToken): Promise<void> {
const searchPs = [ const searchPs = [
this.searchSettingsTarget(query, searchProvider, ConfigurationTarget.WORKSPACE, groupId, groupLabel, groupOrder, token), this.searchSettingsTarget(query, searchProvider, ConfigurationTarget.WORKSPACE, groupId, groupLabel, groupOrder, token),
this.searchSettingsTarget(query, searchProvider, ConfigurationTarget.USER, groupId, groupLabel, groupOrder, token) this.searchSettingsTarget(query, searchProvider, ConfigurationTarget.USER, groupId, groupLabel, groupOrder, token)
...@@ -513,7 +512,7 @@ class PreferencesRenderersController extends Disposable { ...@@ -513,7 +512,7 @@ class PreferencesRenderersController extends Disposable {
} }
return TPromise.join(searchPs).then(() => { }); return Promise.all(searchPs).then(() => { });
} }
private searchSettingsTarget(query: string, provider: ISearchProvider, target: SettingsTarget, groupId: string, groupLabel: string, groupOrder: number, token?: CancellationToken): Promise<void> { private searchSettingsTarget(query: string, provider: ISearchProvider, target: SettingsTarget, groupId: string, groupLabel: string, groupOrder: number, token?: CancellationToken): Promise<void> {
...@@ -530,7 +529,7 @@ class PreferencesRenderersController extends Disposable { ...@@ -530,7 +529,7 @@ class PreferencesRenderersController extends Disposable {
this._onDidFilterResultsCountChange.fire({ target, count }); this._onDidFilterResultsCountChange.fire({ target, count });
}, err => { }, err => {
if (!isPromiseCanceledError(err)) { if (!isPromiseCanceledError(err)) {
return TPromise.wrapError(err); return Promise.reject(err);
} }
return null; return null;
...@@ -582,9 +581,9 @@ class PreferencesRenderersController extends Disposable { ...@@ -582,9 +581,9 @@ class PreferencesRenderersController extends Disposable {
} }
} }
private _filterOrSearchPreferences(filter: string, preferencesRenderer: IPreferencesRenderer<ISetting>, provider: ISearchProvider, groupId: string, groupLabel: string, groupOrder: number, token?: CancellationToken): TPromise<IFilterResult> { private _filterOrSearchPreferences(filter: string, preferencesRenderer: IPreferencesRenderer<ISetting>, provider: ISearchProvider, groupId: string, groupLabel: string, groupOrder: number, token?: CancellationToken): Promise<IFilterResult> {
if (!preferencesRenderer) { if (!preferencesRenderer) {
return TPromise.wrap(null); return Promise.resolve(null);
} }
const model = <ISettingsEditorModel>preferencesRenderer.preferencesModel; const model = <ISettingsEditorModel>preferencesRenderer.preferencesModel;
...@@ -594,12 +593,12 @@ class PreferencesRenderersController extends Disposable { ...@@ -594,12 +593,12 @@ class PreferencesRenderersController extends Disposable {
}); });
} }
private _filterOrSearchPreferencesModel(filter: string, model: ISettingsEditorModel, provider: ISearchProvider, groupId: string, groupLabel: string, groupOrder: number, token?: CancellationToken): TPromise<IFilterResult> { private _filterOrSearchPreferencesModel(filter: string, model: ISettingsEditorModel, provider: ISearchProvider, groupId: string, groupLabel: string, groupOrder: number, token?: CancellationToken): Promise<IFilterResult> {
const searchP = provider ? provider.searchModel(model, token) : TPromise.wrap(null); const searchP = provider ? provider.searchModel(model, token) : Promise.resolve(null);
return searchP return searchP
.then<ISearchResult>(null, err => { .then<ISearchResult>(null, err => {
if (isPromiseCanceledError(err)) { if (isPromiseCanceledError(err)) {
return TPromise.wrapError(err); return Promise.reject(err);
} else { } else {
/* __GDPR__ /* __GDPR__
"defaultSettings.searchError" : { "defaultSettings.searchError" : {
...@@ -845,10 +844,10 @@ class SideBySidePreferencesWidget extends Widget { ...@@ -845,10 +844,10 @@ class SideBySidePreferencesWidget extends Widget {
this._register(focusTracker.onDidFocus(() => this._onFocus.fire())); this._register(focusTracker.onDidFocus(() => this._onFocus.fire()));
} }
public setInput(defaultPreferencesEditorInput: DefaultPreferencesEditorInput, editablePreferencesEditorInput: EditorInput, options: EditorOptions, token: CancellationToken): TPromise<{ defaultPreferencesRenderer?: IPreferencesRenderer<ISetting>, editablePreferencesRenderer?: IPreferencesRenderer<ISetting> }> { public setInput(defaultPreferencesEditorInput: DefaultPreferencesEditorInput, editablePreferencesEditorInput: EditorInput, options: EditorOptions, token: CancellationToken): Promise<{ defaultPreferencesRenderer?: IPreferencesRenderer<ISetting>, editablePreferencesRenderer?: IPreferencesRenderer<ISetting> }> {
this.getOrCreateEditablePreferencesEditor(editablePreferencesEditorInput); this.getOrCreateEditablePreferencesEditor(editablePreferencesEditorInput);
this.settingsTargetsWidget.settingsTarget = this.getSettingsTarget(editablePreferencesEditorInput.getResource()); this.settingsTargetsWidget.settingsTarget = this.getSettingsTarget(editablePreferencesEditorInput.getResource());
return TPromise.join([ return Promise.all([
this.updateInput(this.defaultPreferencesEditor, defaultPreferencesEditorInput, DefaultSettingsEditorContribution.ID, editablePreferencesEditorInput.getResource(), options, token), this.updateInput(this.defaultPreferencesEditor, defaultPreferencesEditorInput, DefaultSettingsEditorContribution.ID, editablePreferencesEditorInput.getResource(), options, token),
this.updateInput(this.editablePreferencesEditor, editablePreferencesEditorInput, SettingsEditorContribution.ID, defaultPreferencesEditorInput.getResource(), options, token) this.updateInput(this.editablePreferencesEditor, editablePreferencesEditorInput, SettingsEditorContribution.ID, defaultPreferencesEditorInput.getResource(), options, token)
]) ])
...@@ -1076,13 +1075,13 @@ export class DefaultPreferencesEditor extends BaseTextEditor { ...@@ -1076,13 +1075,13 @@ export class DefaultPreferencesEditor extends BaseTextEditor {
interface ISettingsEditorContribution extends editorCommon.IEditorContribution { interface ISettingsEditorContribution extends editorCommon.IEditorContribution {
updatePreferencesRenderer(associatedPreferencesModelUri: URI): TPromise<IPreferencesRenderer<ISetting>>; updatePreferencesRenderer(associatedPreferencesModelUri: URI): Thenable<IPreferencesRenderer<ISetting>>;
} }
abstract class AbstractSettingsEditorContribution extends Disposable implements ISettingsEditorContribution { abstract class AbstractSettingsEditorContribution extends Disposable implements ISettingsEditorContribution {
private preferencesRendererCreationPromise: TPromise<IPreferencesRenderer<ISetting>>; private preferencesRendererCreationPromise: Thenable<IPreferencesRenderer<ISetting>>;
constructor(protected editor: ICodeEditor, constructor(protected editor: ICodeEditor,
@IInstantiationService protected instantiationService: IInstantiationService, @IInstantiationService protected instantiationService: IInstantiationService,
...@@ -1093,7 +1092,7 @@ abstract class AbstractSettingsEditorContribution extends Disposable implements ...@@ -1093,7 +1092,7 @@ abstract class AbstractSettingsEditorContribution extends Disposable implements
this._register(this.editor.onDidChangeModel(() => this._onModelChanged())); this._register(this.editor.onDidChangeModel(() => this._onModelChanged()));
} }
updatePreferencesRenderer(associatedPreferencesModelUri: URI): TPromise<IPreferencesRenderer<ISetting>> { updatePreferencesRenderer(associatedPreferencesModelUri: URI): Thenable<IPreferencesRenderer<ISetting>> {
if (!this.preferencesRendererCreationPromise) { if (!this.preferencesRendererCreationPromise) {
this.preferencesRendererCreationPromise = this._createPreferencesRenderer(); this.preferencesRendererCreationPromise = this._createPreferencesRenderer();
} }
...@@ -1103,7 +1102,7 @@ abstract class AbstractSettingsEditorContribution extends Disposable implements ...@@ -1103,7 +1102,7 @@ abstract class AbstractSettingsEditorContribution extends Disposable implements
.then(changed => changed ? this._updatePreferencesRenderer(associatedPreferencesModelUri) : this.preferencesRendererCreationPromise); .then(changed => changed ? this._updatePreferencesRenderer(associatedPreferencesModelUri) : this.preferencesRendererCreationPromise);
} }
return TPromise.as(null); return Promise.resolve(null);
} }
protected _onModelChanged(): void { protected _onModelChanged(): void {
...@@ -1114,13 +1113,13 @@ abstract class AbstractSettingsEditorContribution extends Disposable implements ...@@ -1114,13 +1113,13 @@ abstract class AbstractSettingsEditorContribution extends Disposable implements
} }
} }
private _hasAssociatedPreferencesModelChanged(associatedPreferencesModelUri: URI): TPromise<boolean> { private _hasAssociatedPreferencesModelChanged(associatedPreferencesModelUri: URI): Thenable<boolean> {
return this.preferencesRendererCreationPromise.then(preferencesRenderer => { return this.preferencesRendererCreationPromise.then(preferencesRenderer => {
return !(preferencesRenderer && preferencesRenderer.getAssociatedPreferencesModel() && preferencesRenderer.getAssociatedPreferencesModel().uri.toString() === associatedPreferencesModelUri.toString()); return !(preferencesRenderer && preferencesRenderer.getAssociatedPreferencesModel() && preferencesRenderer.getAssociatedPreferencesModel().uri.toString() === associatedPreferencesModelUri.toString());
}); });
} }
private _updatePreferencesRenderer(associatedPreferencesModelUri: URI): TPromise<IPreferencesRenderer<ISetting>> { private _updatePreferencesRenderer(associatedPreferencesModelUri: URI): Thenable<IPreferencesRenderer<ISetting>> {
return this.preferencesService.createPreferencesEditorModel<ISetting>(associatedPreferencesModelUri) return this.preferencesService.createPreferencesEditorModel<ISetting>(associatedPreferencesModelUri)
.then(associatedPreferencesEditorModel => { .then(associatedPreferencesEditorModel => {
return this.preferencesRendererCreationPromise.then(preferencesRenderer => { return this.preferencesRendererCreationPromise.then(preferencesRenderer => {
...@@ -1148,7 +1147,7 @@ abstract class AbstractSettingsEditorContribution extends Disposable implements ...@@ -1148,7 +1147,7 @@ abstract class AbstractSettingsEditorContribution extends Disposable implements
preferencesRenderer.dispose(); preferencesRenderer.dispose();
} }
}); });
this.preferencesRendererCreationPromise = TPromise.as(null); this.preferencesRendererCreationPromise = Promise.resolve(null);
} }
} }
...@@ -1157,7 +1156,7 @@ abstract class AbstractSettingsEditorContribution extends Disposable implements ...@@ -1157,7 +1156,7 @@ abstract class AbstractSettingsEditorContribution extends Disposable implements
super.dispose(); super.dispose();
} }
protected abstract _createPreferencesRenderer(): TPromise<IPreferencesRenderer<ISetting>>; protected abstract _createPreferencesRenderer(): Thenable<IPreferencesRenderer<ISetting>>;
abstract getId(): string; abstract getId(): string;
} }
...@@ -1169,7 +1168,7 @@ class DefaultSettingsEditorContribution extends AbstractSettingsEditorContributi ...@@ -1169,7 +1168,7 @@ class DefaultSettingsEditorContribution extends AbstractSettingsEditorContributi
return DefaultSettingsEditorContribution.ID; return DefaultSettingsEditorContribution.ID;
} }
protected _createPreferencesRenderer(): TPromise<IPreferencesRenderer<ISetting>> { protected _createPreferencesRenderer(): Thenable<IPreferencesRenderer<ISetting>> {
return this.preferencesService.createPreferencesEditorModel(this.editor.getModel().uri) return this.preferencesService.createPreferencesEditorModel(this.editor.getModel().uri)
.then(editorModel => { .then(editorModel => {
if (editorModel instanceof DefaultSettingsEditorModel && this.editor.getModel()) { if (editorModel instanceof DefaultSettingsEditorModel && this.editor.getModel()) {
...@@ -1199,7 +1198,7 @@ class SettingsEditorContribution extends AbstractSettingsEditorContribution impl ...@@ -1199,7 +1198,7 @@ class SettingsEditorContribution extends AbstractSettingsEditorContribution impl
return SettingsEditorContribution.ID; return SettingsEditorContribution.ID;
} }
protected _createPreferencesRenderer(): TPromise<IPreferencesRenderer<ISetting>> { protected _createPreferencesRenderer(): Thenable<IPreferencesRenderer<ISetting>> {
if (this.isSettingsModel()) { if (this.isSettingsModel()) {
return this.preferencesService.createPreferencesEditorModel(this.editor.getModel().uri) return this.preferencesService.createPreferencesEditorModel(this.editor.getModel().uri)
.then(settingsModel => { .then(settingsModel => {
......
...@@ -14,7 +14,6 @@ import { MarkdownString } from 'vs/base/common/htmlContent'; ...@@ -14,7 +14,6 @@ import { MarkdownString } from 'vs/base/common/htmlContent';
import { KeyCode } from 'vs/base/common/keyCodes'; import { KeyCode } from 'vs/base/common/keyCodes';
import { Disposable, dispose, IDisposable } from 'vs/base/common/lifecycle'; import { Disposable, dispose, IDisposable } from 'vs/base/common/lifecycle';
import { URI } from 'vs/base/common/uri'; import { URI } from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base';
import { IMarginData } from 'vs/editor/browser/controller/mouseTarget'; import { IMarginData } from 'vs/editor/browser/controller/mouseTarget';
import { ICodeEditor, IEditorMouseEvent, IViewZone, MouseTargetType } from 'vs/editor/browser/editorBrowser'; import { ICodeEditor, IEditorMouseEvent, IViewZone, MouseTargetType } from 'vs/editor/browser/editorBrowser';
import { ICursorPositionChangedEvent } from 'vs/editor/common/controller/cursorEvents'; import { ICursorPositionChangedEvent } from 'vs/editor/common/controller/cursorEvents';
...@@ -549,13 +548,13 @@ export class SettingsTargetsWidget extends Widget { ...@@ -549,13 +548,13 @@ export class SettingsTargetsWidget extends Widget {
} }
} }
public updateTarget(settingsTarget: SettingsTarget): TPromise<void> { public updateTarget(settingsTarget: SettingsTarget): Promise<void> {
const isSameTarget = this.settingsTarget === settingsTarget || settingsTarget instanceof URI && this.settingsTarget instanceof URI && this.settingsTarget.toString() === settingsTarget.toString(); const isSameTarget = this.settingsTarget === settingsTarget || settingsTarget instanceof URI && this.settingsTarget instanceof URI && this.settingsTarget.toString() === settingsTarget.toString();
if (!isSameTarget) { if (!isSameTarget) {
this.settingsTarget = settingsTarget; this.settingsTarget = settingsTarget;
this._onDidTargetChange.fire(this.settingsTarget); this._onDidTargetChange.fire(this.settingsTarget);
} }
return TPromise.as(null); return Promise.resolve(null);
} }
private update(): void { private update(): void {
......
...@@ -23,7 +23,6 @@ import { KeyCode } from 'vs/base/common/keyCodes'; ...@@ -23,7 +23,6 @@ import { KeyCode } from 'vs/base/common/keyCodes';
import { dispose, IDisposable } from 'vs/base/common/lifecycle'; import { dispose, IDisposable } from 'vs/base/common/lifecycle';
import { escapeRegExpCharacters, startsWith } from 'vs/base/common/strings'; import { escapeRegExpCharacters, startsWith } from 'vs/base/common/strings';
import { URI } from 'vs/base/common/uri'; import { URI } from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base';
import { IAccessibilityProvider, IDataSource, IFilter, IRenderer as ITreeRenderer, ITree, ITreeConfiguration } from 'vs/base/parts/tree/browser/tree'; import { IAccessibilityProvider, IDataSource, IFilter, IRenderer as ITreeRenderer, ITree, ITreeConfiguration } from 'vs/base/parts/tree/browser/tree';
import { DefaultTreestyler } from 'vs/base/parts/tree/browser/treeDefaults'; import { DefaultTreestyler } from 'vs/base/parts/tree/browser/treeDefaults';
import { Tree } from 'vs/base/parts/tree/browser/treeImpl'; import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
...@@ -186,8 +185,8 @@ export class SettingsDataSource implements IDataSource { ...@@ -186,8 +185,8 @@ export class SettingsDataSource implements IDataSource {
return false; return false;
} }
getChildren(tree: ITree, element: SettingsTreeElement): TPromise<any> { getChildren(tree: ITree, element: SettingsTreeElement): Promise<any> {
return TPromise.as(this._getChildren(element)); return Promise.resolve(this._getChildren(element));
} }
private _getChildren(element: SettingsTreeElement): SettingsTreeElement[] { private _getChildren(element: SettingsTreeElement): SettingsTreeElement[] {
...@@ -199,8 +198,8 @@ export class SettingsDataSource implements IDataSource { ...@@ -199,8 +198,8 @@ export class SettingsDataSource implements IDataSource {
} }
} }
getParent(tree: ITree, element: SettingsTreeElement): TPromise<any> { getParent(tree: ITree, element: SettingsTreeElement): Promise<any> {
return TPromise.wrap(element && element.parent); return Promise.resolve(element && element.parent);
} }
shouldAutoexpand(): boolean { shouldAutoexpand(): boolean {
...@@ -241,7 +240,7 @@ export class SimplePagedDataSource implements IDataSource { ...@@ -241,7 +240,7 @@ export class SimplePagedDataSource implements IDataSource {
return this.realDataSource.hasChildren(tree, element); return this.realDataSource.hasChildren(tree, element);
} }
getChildren(tree: ITree, element: SettingsTreeGroupElement): TPromise<any> { getChildren(tree: ITree, element: SettingsTreeGroupElement): Thenable<any> {
return this.realDataSource.getChildren(tree, element).then(realChildren => { return this.realDataSource.getChildren(tree, element).then(realChildren => {
return this._getChildren(realChildren); return this._getChildren(realChildren);
}); });
...@@ -258,7 +257,7 @@ export class SimplePagedDataSource implements IDataSource { ...@@ -258,7 +257,7 @@ export class SimplePagedDataSource implements IDataSource {
} }
} }
getParent(tree: ITree, element: any): TPromise<any> { getParent(tree: ITree, element: any): Thenable<any> {
return this.realDataSource.getParent(tree, element); return this.realDataSource.getParent(tree, element);
} }
...@@ -400,7 +399,7 @@ export class SettingsRenderer implements ITreeRenderer { ...@@ -400,7 +399,7 @@ export class SettingsRenderer implements ITreeRenderer {
this._onDidChangeSetting.fire({ key: context.setting.key, value: undefined, type: context.setting.type as SettingValueType }); this._onDidChangeSetting.fire({ key: context.setting.key, value: undefined, type: context.setting.type as SettingValueType });
} }
return TPromise.wrap(null); return Promise.resolve(null);
}), }),
new Separator(), new Separator(),
this.instantiationService.createInstance(CopySettingIdAction), this.instantiationService.createInstance(CopySettingIdAction),
...@@ -1436,12 +1435,12 @@ export class SettingsAccessibilityProvider implements IAccessibilityProvider { ...@@ -1436,12 +1435,12 @@ export class SettingsAccessibilityProvider implements IAccessibilityProvider {
} }
class NonExpandableOrSelectableTree extends Tree { class NonExpandableOrSelectableTree extends Tree {
expand(): TPromise<any> { expand(): Promise<any> {
return TPromise.wrap(null); return Promise.resolve(null);
} }
collapse(): TPromise<any> { collapse(): Promise<any> {
return TPromise.wrap(null); return Promise.resolve(null);
} }
public setFocus(element?: any, eventPayload?: any): void { public setFocus(element?: any, eventPayload?: any): void {
...@@ -1624,12 +1623,12 @@ class CopySettingIdAction extends Action { ...@@ -1624,12 +1623,12 @@ class CopySettingIdAction extends Action {
super(CopySettingIdAction.ID, CopySettingIdAction.LABEL); super(CopySettingIdAction.ID, CopySettingIdAction.LABEL);
} }
run(context: SettingsTreeSettingElement): TPromise<void> { run(context: SettingsTreeSettingElement): Promise<void> {
if (context) { if (context) {
this.clipboardService.writeText(context.setting.key); this.clipboardService.writeText(context.setting.key);
} }
return TPromise.as(null); return Promise.resolve(null);
} }
} }
...@@ -1643,12 +1642,12 @@ class CopySettingAsJSONAction extends Action { ...@@ -1643,12 +1642,12 @@ class CopySettingAsJSONAction extends Action {
super(CopySettingAsJSONAction.ID, CopySettingAsJSONAction.LABEL); super(CopySettingAsJSONAction.ID, CopySettingAsJSONAction.LABEL);
} }
run(context: SettingsTreeSettingElement): TPromise<void> { run(context: SettingsTreeSettingElement): Promise<void> {
if (context) { if (context) {
const jsonResult = `"${context.setting.key}": ${JSON.stringify(context.value, undefined, ' ')}`; const jsonResult = `"${context.setting.key}": ${JSON.stringify(context.value, undefined, ' ')}`;
this.clipboardService.writeText(jsonResult); this.clipboardService.writeText(jsonResult);
} }
return TPromise.as(null); return Promise.resolve(null);
} }
} }
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
import * as DOM from 'vs/base/browser/dom'; import * as DOM from 'vs/base/browser/dom';
import { ScrollbarVisibility } from 'vs/base/common/scrollable'; import { ScrollbarVisibility } from 'vs/base/common/scrollable';
import { TPromise } from 'vs/base/common/winjs.base';
import { IDataSource, IRenderer, ITree, ITreeConfiguration, ITreeOptions } from 'vs/base/parts/tree/browser/tree'; import { IDataSource, IRenderer, ITree, ITreeConfiguration, ITreeOptions } from 'vs/base/parts/tree/browser/tree';
import { DefaultTreestyler } from 'vs/base/parts/tree/browser/treeDefaults'; import { DefaultTreestyler } from 'vs/base/parts/tree/browser/treeDefaults';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
...@@ -106,8 +105,8 @@ export class TOCDataSource implements IDataSource { ...@@ -106,8 +105,8 @@ export class TOCDataSource implements IDataSource {
return false; return false;
} }
getChildren(tree: ITree, element: TOCTreeElement): TPromise<SettingsTreeElement[]> { getChildren(tree: ITree, element: TOCTreeElement): Promise<SettingsTreeElement[]> {
return TPromise.as(this._getChildren(element)); return Promise.resolve(this._getChildren(element));
} }
private _getChildren(element: TOCTreeElement): SettingsTreeElement[] { private _getChildren(element: TOCTreeElement): SettingsTreeElement[] {
...@@ -115,8 +114,8 @@ export class TOCDataSource implements IDataSource { ...@@ -115,8 +114,8 @@ export class TOCDataSource implements IDataSource {
.filter(child => child instanceof SettingsTreeGroupElement); .filter(child => child instanceof SettingsTreeGroupElement);
} }
getParent(tree: ITree, element: TOCTreeElement): TPromise<any> { getParent(tree: ITree, element: TOCTreeElement): Promise<any> {
return TPromise.wrap(element instanceof SettingsTreeGroupElement && element.parent); return Promise.resolve(element instanceof SettingsTreeGroupElement && element.parent);
} }
} }
......
...@@ -41,7 +41,7 @@ export interface IPreferencesSearchService { ...@@ -41,7 +41,7 @@ export interface IPreferencesSearchService {
} }
export interface ISearchProvider { export interface ISearchProvider {
searchModel(preferencesModel: ISettingsEditorModel, token?: CancellationToken): TPromise<ISearchResult>; searchModel(preferencesModel: ISettingsEditorModel, token?: CancellationToken): Promise<ISearchResult>;
} }
export interface IKeybindingsEditor extends IEditor { export interface IKeybindingsEditor extends IEditor {
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
import { IModelService } from 'vs/editor/common/services/modelService'; import { IModelService } from 'vs/editor/common/services/modelService';
import { IModeService } from 'vs/editor/common/services/modeService'; import { IModeService } from 'vs/editor/common/services/modeService';
import { URI } from 'vs/base/common/uri'; import { URI } from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base';
import { ITextModel } from 'vs/editor/common/model'; import { ITextModel } from 'vs/editor/common/model';
import * as JSONContributionRegistry from 'vs/platform/jsonschemas/common/jsonContributionRegistry'; import * as JSONContributionRegistry from 'vs/platform/jsonschemas/common/jsonContributionRegistry';
import { Registry } from 'vs/platform/registry/common/platform'; import { Registry } from 'vs/platform/registry/common/platform';
...@@ -109,14 +108,14 @@ export class PreferencesContribution implements IWorkbenchContribution { ...@@ -109,14 +108,14 @@ export class PreferencesContribution implements IWorkbenchContribution {
private start(): void { private start(): void {
this.textModelResolverService.registerTextModelContentProvider('vscode', { this.textModelResolverService.registerTextModelContentProvider('vscode', {
provideTextContent: (uri: URI): TPromise<ITextModel> => { provideTextContent: (uri: URI): Thenable<ITextModel> => {
if (uri.scheme !== 'vscode') { if (uri.scheme !== 'vscode') {
return null; return null;
} }
if (uri.authority === 'schemas') { if (uri.authority === 'schemas') {
const schemaModel = this.getSchemaModel(uri); const schemaModel = this.getSchemaModel(uri);
if (schemaModel) { if (schemaModel) {
return TPromise.as(schemaModel); return Promise.resolve(schemaModel);
} }
} }
return this.preferencesService.resolveModel(uri); return this.preferencesService.resolveModel(uri);
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { TPromise } from 'vs/base/common/winjs.base';
import { ISettingsEditorModel, ISetting, ISettingsGroup, IFilterMetadata, ISearchResult, IGroupFilter, ISettingMatcher, IScoredResults, ISettingMatch, IRemoteSetting, IExtensionSetting } from 'vs/workbench/services/preferences/common/preferences'; import { ISettingsEditorModel, ISetting, ISettingsGroup, IFilterMetadata, ISearchResult, IGroupFilter, ISettingMatcher, IScoredResults, ISettingMatch, IRemoteSetting, IExtensionSetting } from 'vs/workbench/services/preferences/common/preferences';
import { IRange } from 'vs/editor/common/core/range'; import { IRange } from 'vs/editor/common/core/range';
import { distinct, top } from 'vs/base/common/arrays'; import { distinct, top } from 'vs/base/common/arrays';
...@@ -32,7 +31,7 @@ export interface IEndpointDetails { ...@@ -32,7 +31,7 @@ export interface IEndpointDetails {
export class PreferencesSearchService extends Disposable implements IPreferencesSearchService { export class PreferencesSearchService extends Disposable implements IPreferencesSearchService {
_serviceBrand: any; _serviceBrand: any;
private _installedExtensions: TPromise<ILocalExtension[]>; private _installedExtensions: Promise<ILocalExtension[]>;
constructor( constructor(
@IWorkspaceConfigurationService private configurationService: IWorkspaceConfigurationService, @IWorkspaceConfigurationService private configurationService: IWorkspaceConfigurationService,
...@@ -104,9 +103,9 @@ export class LocalSearchProvider implements ISearchProvider { ...@@ -104,9 +103,9 @@ export class LocalSearchProvider implements ISearchProvider {
.trim(); .trim();
} }
searchModel(preferencesModel: ISettingsEditorModel, token?: CancellationToken): TPromise<ISearchResult> { searchModel(preferencesModel: ISettingsEditorModel, token?: CancellationToken): Promise<ISearchResult> {
if (!this._filter) { if (!this._filter) {
return TPromise.wrap(null); return Promise.resolve(null);
} }
let orderedScore = LocalSearchProvider.START_SCORE; // Sort is not stable let orderedScore = LocalSearchProvider.START_SCORE; // Sort is not stable
...@@ -126,12 +125,12 @@ export class LocalSearchProvider implements ISearchProvider { ...@@ -126,12 +125,12 @@ export class LocalSearchProvider implements ISearchProvider {
const filterMatches = preferencesModel.filterSettings(this._filter, this.getGroupFilter(this._filter), settingMatcher); const filterMatches = preferencesModel.filterSettings(this._filter, this.getGroupFilter(this._filter), settingMatcher);
if (filterMatches[0] && filterMatches[0].score === LocalSearchProvider.EXACT_MATCH_SCORE) { if (filterMatches[0] && filterMatches[0].score === LocalSearchProvider.EXACT_MATCH_SCORE) {
return TPromise.wrap({ return Promise.resolve({
filterMatches: filterMatches.slice(0, 1), filterMatches: filterMatches.slice(0, 1),
exactMatch: true exactMatch: true
}); });
} else { } else {
return TPromise.wrap({ return Promise.resolve({
filterMatches filterMatches
}); });
} }
...@@ -164,19 +163,19 @@ class RemoteSearchProvider implements ISearchProvider { ...@@ -164,19 +163,19 @@ class RemoteSearchProvider implements ISearchProvider {
private static readonly MAX_REQUESTS = 10; private static readonly MAX_REQUESTS = 10;
private static readonly NEW_EXTENSIONS_MIN_SCORE = 1; private static readonly NEW_EXTENSIONS_MIN_SCORE = 1;
private _remoteSearchP: TPromise<IFilterMetadata>; private _remoteSearchP: Promise<IFilterMetadata>;
constructor(private options: IRemoteSearchProviderOptions, private installedExtensions: TPromise<ILocalExtension[]>, constructor(private options: IRemoteSearchProviderOptions, private installedExtensions: Promise<ILocalExtension[]>,
@IEnvironmentService private environmentService: IEnvironmentService, @IEnvironmentService private environmentService: IEnvironmentService,
@IRequestService private requestService: IRequestService, @IRequestService private requestService: IRequestService,
@ILogService private logService: ILogService @ILogService private logService: ILogService
) { ) {
this._remoteSearchP = this.options.filter ? this._remoteSearchP = this.options.filter ?
TPromise.wrap(this.getSettingsForFilter(this.options.filter)) : Promise.resolve(this.getSettingsForFilter(this.options.filter)) :
TPromise.wrap(null); Promise.resolve(null);
} }
searchModel(preferencesModel: ISettingsEditorModel, token?: CancellationToken): TPromise<ISearchResult> { searchModel(preferencesModel: ISettingsEditorModel, token?: CancellationToken): Promise<ISearchResult> {
return this._remoteSearchP.then(remoteResult => { return this._remoteSearchP.then(remoteResult => {
if (!remoteResult) { if (!remoteResult) {
return null; return null;
...@@ -239,7 +238,7 @@ class RemoteSearchProvider implements ISearchProvider { ...@@ -239,7 +238,7 @@ class RemoteSearchProvider implements ISearchProvider {
} }
} }
return TPromise.join(allRequestDetails.map(details => this.getSettingsFromBing(details))).then(allResponses => { return Promise.all(allRequestDetails.map(details => this.getSettingsFromBing(details))).then(allResponses => {
// Merge all IFilterMetadata // Merge all IFilterMetadata
const metadata = allResponses[0]; const metadata = allResponses[0];
metadata.requestCount = 1; metadata.requestCount = 1;
...@@ -253,7 +252,7 @@ class RemoteSearchProvider implements ISearchProvider { ...@@ -253,7 +252,7 @@ class RemoteSearchProvider implements ISearchProvider {
}); });
} }
private getSettingsFromBing(details: IBingRequestDetails): TPromise<IFilterMetadata> { private getSettingsFromBing(details: IBingRequestDetails): Promise<IFilterMetadata> {
this.logService.debug(`Searching settings via ${details.url}`); this.logService.debug(`Searching settings via ${details.url}`);
if (details.body) { if (details.body) {
this.logService.debug(`Body: ${details.body}`); this.logService.debug(`Body: ${details.body}`);
......
...@@ -14,7 +14,6 @@ import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cance ...@@ -14,7 +14,6 @@ import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cance
import * as collections from 'vs/base/common/collections'; import * as collections from 'vs/base/common/collections';
import { getErrorMessage, isPromiseCanceledError } from 'vs/base/common/errors'; import { getErrorMessage, isPromiseCanceledError } from 'vs/base/common/errors';
import { URI } from 'vs/base/common/uri'; import { URI } from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base';
import { Tree } from 'vs/base/parts/tree/browser/treeImpl'; import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
import { collapseAll, expandAll } from 'vs/base/parts/tree/browser/treeUtils'; import { collapseAll, expandAll } from 'vs/base/parts/tree/browser/treeUtils';
import 'vs/css!./media/settingsEditor2'; import 'vs/css!./media/settingsEditor2';
...@@ -211,7 +210,7 @@ export class SettingsEditor2 extends BaseEditor { ...@@ -211,7 +210,7 @@ export class SettingsEditor2 extends BaseEditor {
} }
this._setOptions(options); this._setOptions(options);
this.render(token); return this.render(token);
}) })
.then(() => { .then(() => {
// Init TOC selection // Init TOC selection
...@@ -471,7 +470,7 @@ export class SettingsEditor2 extends BaseEditor { ...@@ -471,7 +470,7 @@ export class SettingsEditor2 extends BaseEditor {
} }
} }
private openSettingsFile(query?: string): TPromise<IEditor> { private openSettingsFile(query?: string): Thenable<IEditor> {
const currentSettingsTarget = this.settingsTargetsWidget.settingsTarget; const currentSettingsTarget = this.settingsTargetsWidget.settingsTarget;
const options: ISettingsEditorOptions = { query }; const options: ISettingsEditorOptions = { query };
...@@ -592,7 +591,7 @@ export class SettingsEditor2 extends BaseEditor { ...@@ -592,7 +591,7 @@ export class SettingsEditor2 extends BaseEditor {
} }
if (element && (!e.payload || !e.payload.fromScroll)) { if (element && (!e.payload || !e.payload.fromScroll)) {
let refreshP = TPromise.wrap(null); let refreshP: Thenable<void> = Promise.resolve(null);
if (this.settingsTreeDataSource.pageTo(element.index, true)) { if (this.settingsTreeDataSource.pageTo(element.index, true)) {
refreshP = this.renderTree(); refreshP = this.renderTree();
} }
...@@ -724,7 +723,7 @@ export class SettingsEditor2 extends BaseEditor { ...@@ -724,7 +723,7 @@ export class SettingsEditor2 extends BaseEditor {
} }
} }
private updateChangedSetting(key: string, value: any): TPromise<void> { private updateChangedSetting(key: string, value: any): Thenable<void> {
// ConfigurationService displays the error if this fails. // ConfigurationService displays the error if this fails.
// Force a render afterwards because onDidConfigurationUpdate doesn't fire if the update doesn't result in an effective setting value change // Force a render afterwards because onDidConfigurationUpdate doesn't fire if the update doesn't result in an effective setting value change
const settingsTarget = this.settingsTargetsWidget.settingsTarget; const settingsTarget = this.settingsTargetsWidget.settingsTarget;
...@@ -815,7 +814,7 @@ export class SettingsEditor2 extends BaseEditor { ...@@ -815,7 +814,7 @@ export class SettingsEditor2 extends BaseEditor {
this.telemetryService.publicLog('settingsEditor.settingModified', data); this.telemetryService.publicLog('settingsEditor.settingModified', data);
} }
private render(token: CancellationToken): TPromise<any> { private render(token: CancellationToken): Thenable<any> {
if (this.input) { if (this.input) {
return this.input.resolve() return this.input.resolve()
.then((model: Settings2EditorModel) => { .then((model: Settings2EditorModel) => {
...@@ -828,7 +827,7 @@ export class SettingsEditor2 extends BaseEditor { ...@@ -828,7 +827,7 @@ export class SettingsEditor2 extends BaseEditor {
return this.onConfigUpdate(); return this.onConfigUpdate();
}); });
} }
return TPromise.as(null); return Promise.resolve(null);
} }
private onSearchModeToggled(): void { private onSearchModeToggled(): void {
...@@ -863,7 +862,7 @@ export class SettingsEditor2 extends BaseEditor { ...@@ -863,7 +862,7 @@ export class SettingsEditor2 extends BaseEditor {
}); });
} }
private onConfigUpdate(keys?: string[], forceRefresh = false): TPromise<void> { private onConfigUpdate(keys?: string[], forceRefresh = false): Thenable<void> {
if (keys && this.settingsTreeModel) { if (keys && this.settingsTreeModel) {
return this.updateElementsByKey(keys); return this.updateElementsByKey(keys);
} }
...@@ -916,10 +915,10 @@ export class SettingsEditor2 extends BaseEditor { ...@@ -916,10 +915,10 @@ export class SettingsEditor2 extends BaseEditor {
} }
} }
return TPromise.wrap(null); return Promise.resolve(null);
} }
private updateElementsByKey(keys: string[]): TPromise<void> { private updateElementsByKey(keys: string[]): Thenable<void> {
if (keys.length) { if (keys.length) {
if (this.searchResultModel) { if (this.searchResultModel) {
keys.forEach(key => this.searchResultModel.updateElementsByName(key)); keys.forEach(key => this.searchResultModel.updateElementsByName(key));
...@@ -929,7 +928,7 @@ export class SettingsEditor2 extends BaseEditor { ...@@ -929,7 +928,7 @@ export class SettingsEditor2 extends BaseEditor {
keys.forEach(key => this.settingsTreeModel.updateElementsByName(key)); keys.forEach(key => this.settingsTreeModel.updateElementsByName(key));
} }
return TPromise.join( return Promise.all(
keys.map(key => this.renderTree(key))) keys.map(key => this.renderTree(key)))
.then(() => { }); .then(() => { });
} else { } else {
...@@ -943,10 +942,10 @@ export class SettingsEditor2 extends BaseEditor { ...@@ -943,10 +942,10 @@ export class SettingsEditor2 extends BaseEditor {
null; null;
} }
private renderTree(key?: string, force = false): TPromise<void> { private renderTree(key?: string, force = false): Thenable<void> {
if (!force && key && this.scheduledRefreshes.has(key)) { if (!force && key && this.scheduledRefreshes.has(key)) {
this.updateModifiedLabelForKey(key); this.updateModifiedLabelForKey(key);
return TPromise.wrap(null); return Promise.resolve(null);
} }
// If a setting control is currently focused, schedule a refresh for later // If a setting control is currently focused, schedule a refresh for later
...@@ -960,24 +959,24 @@ export class SettingsEditor2 extends BaseEditor { ...@@ -960,24 +959,24 @@ export class SettingsEditor2 extends BaseEditor {
this.updateModifiedLabelForKey(key); this.updateModifiedLabelForKey(key);
this.scheduleRefresh(focusedSetting, key); this.scheduleRefresh(focusedSetting, key);
return TPromise.wrap(null); return Promise.resolve(null);
} }
} else { } else {
this.scheduleRefresh(focusedSetting); this.scheduleRefresh(focusedSetting);
return TPromise.wrap(null); return Promise.resolve(null);
} }
} }
let refreshP: TPromise<any>; let refreshP: Thenable<any>;
if (key) { if (key) {
const elements = this.currentSettingsModel.getElementsByName(key); const elements = this.currentSettingsModel.getElementsByName(key);
if (elements && elements.length) { if (elements && elements.length) {
// TODO https://github.com/Microsoft/vscode/issues/57360 // TODO https://github.com/Microsoft/vscode/issues/57360
// refreshP = TPromise.join(elements.map(e => this.settingsTree.refresh(e))); // refreshP = Promise.join(elements.map(e => this.settingsTree.refresh(e)));
refreshP = this.settingsTree.refresh(); refreshP = this.settingsTree.refresh();
} else { } else {
// Refresh requested for a key that we don't know about // Refresh requested for a key that we don't know about
return TPromise.wrap(null); return Promise.resolve(null);
} }
} else { } else {
refreshP = this.settingsTree.refresh(); refreshP = this.settingsTree.refresh();
...@@ -1019,7 +1018,7 @@ export class SettingsEditor2 extends BaseEditor { ...@@ -1019,7 +1018,7 @@ export class SettingsEditor2 extends BaseEditor {
return match && match[1]; return match && match[1];
} }
private triggerSearch(query: string): TPromise<void> { private triggerSearch(query: string): Thenable<void> {
this.viewState.tagFilters = new Set<string>(); this.viewState.tagFilters = new Set<string>();
if (query) { if (query) {
const parsedQuery = parseQuery(query); const parsedQuery = parseQuery(query);
...@@ -1126,7 +1125,7 @@ export class SettingsEditor2 extends BaseEditor { ...@@ -1126,7 +1125,7 @@ export class SettingsEditor2 extends BaseEditor {
this.telemetryService.publicLog('settingsEditor.filter', data); this.telemetryService.publicLog('settingsEditor.filter', data);
} }
private triggerFilterPreferences(query: string): TPromise<void> { private triggerFilterPreferences(query: string): Thenable<void> {
if (this.searchInProgress) { if (this.searchInProgress) {
this.searchInProgress.cancel(); this.searchInProgress.cancel();
this.searchInProgress = null; this.searchInProgress = null;
...@@ -1141,26 +1140,26 @@ export class SettingsEditor2 extends BaseEditor { ...@@ -1141,26 +1140,26 @@ export class SettingsEditor2 extends BaseEditor {
this.remoteSearchThrottle.trigger(() => { this.remoteSearchThrottle.trigger(() => {
return searchInProgress && !searchInProgress.token.isCancellationRequested ? return searchInProgress && !searchInProgress.token.isCancellationRequested ?
this.remoteSearchPreferences(query, this.searchInProgress.token) : this.remoteSearchPreferences(query, this.searchInProgress.token) :
TPromise.wrap(null); Promise.resolve(null);
}); });
} }
}); });
} else { } else {
return TPromise.wrap(null); return Promise.resolve(null);
} }
}); });
} }
private localFilterPreferences(query: string, token?: CancellationToken): TPromise<ISearchResult> { private localFilterPreferences(query: string, token?: CancellationToken): Thenable<ISearchResult> {
const localSearchProvider = this.preferencesSearchService.getLocalSearchProvider(query); const localSearchProvider = this.preferencesSearchService.getLocalSearchProvider(query);
return this.filterOrSearchPreferences(query, SearchResultIdx.Local, localSearchProvider, token); return this.filterOrSearchPreferences(query, SearchResultIdx.Local, localSearchProvider, token);
} }
private remoteSearchPreferences(query: string, token?: CancellationToken): TPromise<void> { private remoteSearchPreferences(query: string, token?: CancellationToken): Thenable<void> {
const remoteSearchProvider = this.preferencesSearchService.getRemoteSearchProvider(query); const remoteSearchProvider = this.preferencesSearchService.getRemoteSearchProvider(query);
const newExtSearchProvider = this.preferencesSearchService.getRemoteSearchProvider(query, true); const newExtSearchProvider = this.preferencesSearchService.getRemoteSearchProvider(query, true);
return TPromise.join([ return Promise.all([
this.filterOrSearchPreferences(query, SearchResultIdx.Remote, remoteSearchProvider, token), this.filterOrSearchPreferences(query, SearchResultIdx.Remote, remoteSearchProvider, token),
this.filterOrSearchPreferences(query, SearchResultIdx.NewExtensions, newExtSearchProvider, token) this.filterOrSearchPreferences(query, SearchResultIdx.NewExtensions, newExtSearchProvider, token)
]).then(() => { ]).then(() => {
...@@ -1168,7 +1167,7 @@ export class SettingsEditor2 extends BaseEditor { ...@@ -1168,7 +1167,7 @@ export class SettingsEditor2 extends BaseEditor {
}); });
} }
private filterOrSearchPreferences(query: string, type: SearchResultIdx, searchProvider: ISearchProvider, token?: CancellationToken): TPromise<ISearchResult> { private filterOrSearchPreferences(query: string, type: SearchResultIdx, searchProvider: ISearchProvider, token?: CancellationToken): Thenable<ISearchResult> {
return this._filterOrSearchPreferencesModel(query, this.defaultSettingsEditorModel, searchProvider, token).then(result => { return this._filterOrSearchPreferencesModel(query, this.defaultSettingsEditorModel, searchProvider, token).then(result => {
if (token && token.isCancellationRequested) { if (token && token.isCancellationRequested) {
// Handle cancellation like this because cancellation is lost inside the search provider due to async/await // Handle cancellation like this because cancellation is lost inside the search provider due to async/await
...@@ -1215,12 +1214,12 @@ export class SettingsEditor2 extends BaseEditor { ...@@ -1215,12 +1214,12 @@ export class SettingsEditor2 extends BaseEditor {
} }
} }
private _filterOrSearchPreferencesModel(filter: string, model: ISettingsEditorModel, provider: ISearchProvider, token?: CancellationToken): TPromise<ISearchResult> { private _filterOrSearchPreferencesModel(filter: string, model: ISettingsEditorModel, provider: ISearchProvider, token?: CancellationToken): Thenable<ISearchResult> {
const searchP = provider ? provider.searchModel(model, token) : TPromise.wrap(null); const searchP = provider ? provider.searchModel(model, token) : Promise.resolve(null);
return searchP return searchP
.then<ISearchResult>(null, err => { .then<ISearchResult>(null, err => {
if (isPromiseCanceledError(err)) { if (isPromiseCanceledError(err)) {
return TPromise.wrapError(err); return Promise.reject(err);
} else { } else {
/* __GDPR__ /* __GDPR__
"settingsEditor.searchError" : { "settingsEditor.searchError" : {
...@@ -1284,8 +1283,8 @@ class FilterByTagAction extends Action { ...@@ -1284,8 +1283,8 @@ class FilterByTagAction extends Action {
super(FilterByTagAction.ID, label, 'toggle-filter-tag'); super(FilterByTagAction.ID, label, 'toggle-filter-tag');
} }
run(): TPromise<void> { run(): Thenable<void> {
this.settingsEditor.focusSearch(this.tag === MODIFIED_SETTING_TAG ? `@${this.tag} ` : `@tag:${this.tag} `, false); this.settingsEditor.focusSearch(this.tag === MODIFIED_SETTING_TAG ? `@${this.tag} ` : `@tag:${this.tag} `, false);
return TPromise.as(null); return Promise.resolve(null);
} }
} }
...@@ -10,7 +10,6 @@ import * as network from 'vs/base/common/network'; ...@@ -10,7 +10,6 @@ import * as network from 'vs/base/common/network';
import { assign } from 'vs/base/common/objects'; import { assign } from 'vs/base/common/objects';
import * as strings from 'vs/base/common/strings'; import * as strings from 'vs/base/common/strings';
import { URI } from 'vs/base/common/uri'; import { URI } from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base';
import { getCodeEditor, ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { getCodeEditor, ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { EditOperation } from 'vs/editor/common/core/editOperation'; import { EditOperation } from 'vs/editor/common/core/editOperation';
import { IPosition, Position } from 'vs/editor/common/core/position'; import { IPosition, Position } from 'vs/editor/common/core/position';
...@@ -104,7 +103,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic ...@@ -104,7 +103,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
return this.getEditableSettingsURI(ConfigurationTarget.WORKSPACE_FOLDER, resource); return this.getEditableSettingsURI(ConfigurationTarget.WORKSPACE_FOLDER, resource);
} }
resolveModel(uri: URI): TPromise<ITextModel> { resolveModel(uri: URI): Thenable<ITextModel> {
if (this.isDefaultSettingsResource(uri)) { if (this.isDefaultSettingsResource(uri)) {
const target = this.getConfigurationTargetFromDefaultSettingsResource(uri); const target = this.getConfigurationTargetFromDefaultSettingsResource(uri);
...@@ -131,27 +130,27 @@ export class PreferencesService extends Disposable implements IPreferencesServic ...@@ -131,27 +130,27 @@ export class PreferencesService extends Disposable implements IPreferencesServic
this.modelService.updateModel(model, defaultSettings.getContent(true)); this.modelService.updateModel(model, defaultSettings.getContent(true));
} }
return TPromise.as(model); return Promise.resolve(model);
} }
if (this.defaultSettingsRawResource.toString() === uri.toString()) { if (this.defaultSettingsRawResource.toString() === uri.toString()) {
let defaultSettings: DefaultSettings = this.getDefaultSettings(ConfigurationTarget.USER); let defaultSettings: DefaultSettings = this.getDefaultSettings(ConfigurationTarget.USER);
const languageSelection = this.modeService.create('jsonc'); const languageSelection = this.modeService.create('jsonc');
const model = this._register(this.modelService.createModel(defaultSettings.raw, languageSelection, uri)); const model = this._register(this.modelService.createModel(defaultSettings.raw, languageSelection, uri));
return TPromise.as(model); return Promise.resolve(model);
} }
if (this.defaultKeybindingsResource.toString() === uri.toString()) { if (this.defaultKeybindingsResource.toString() === uri.toString()) {
const defaultKeybindingsEditorModel = this.instantiationService.createInstance(DefaultKeybindingsEditorModel, uri); const defaultKeybindingsEditorModel = this.instantiationService.createInstance(DefaultKeybindingsEditorModel, uri);
const languageSelection = this.modeService.create('jsonc'); const languageSelection = this.modeService.create('jsonc');
const model = this._register(this.modelService.createModel(defaultKeybindingsEditorModel.content, languageSelection, uri)); const model = this._register(this.modelService.createModel(defaultKeybindingsEditorModel.content, languageSelection, uri));
return TPromise.as(model); return Promise.resolve(model);
} }
return TPromise.as(null); return Promise.resolve(null);
} }
createPreferencesEditorModel(uri: URI): TPromise<IPreferencesEditorModel<any>> { createPreferencesEditorModel(uri: URI): Thenable<IPreferencesEditorModel<any>> {
if (this.isDefaultSettingsResource(uri)) { if (this.isDefaultSettingsResource(uri)) {
return this.createDefaultSettingsEditorModel(uri); return this.createDefaultSettingsEditorModel(uri);
} }
...@@ -169,18 +168,18 @@ export class PreferencesService extends Disposable implements IPreferencesServic ...@@ -169,18 +168,18 @@ export class PreferencesService extends Disposable implements IPreferencesServic
return this.createEditableSettingsEditorModel(ConfigurationTarget.WORKSPACE_FOLDER, uri); return this.createEditableSettingsEditorModel(ConfigurationTarget.WORKSPACE_FOLDER, uri);
} }
return TPromise.wrap<IPreferencesEditorModel<any>>(null); return Promise.resolve<IPreferencesEditorModel<any>>(null);
} }
openRawDefaultSettings(): TPromise<IEditor> { openRawDefaultSettings(): Thenable<IEditor> {
return this.editorService.openEditor({ resource: this.defaultSettingsRawResource }); return this.editorService.openEditor({ resource: this.defaultSettingsRawResource });
} }
openRawUserSettings(): TPromise<IEditor> { openRawUserSettings(): Thenable<IEditor> {
return this.editorService.openEditor({ resource: this.userSettingsResource }); return this.editorService.openEditor({ resource: this.userSettingsResource });
} }
openSettings(jsonEditor?: boolean): TPromise<IEditor> { openSettings(jsonEditor?: boolean): Thenable<IEditor> {
jsonEditor = typeof jsonEditor === 'undefined' ? jsonEditor = typeof jsonEditor === 'undefined' ?
this.configurationService.getValue('workbench.settings.editor') === 'json' : this.configurationService.getValue('workbench.settings.editor') === 'json' :
jsonEditor; jsonEditor;
...@@ -195,13 +194,13 @@ export class PreferencesService extends Disposable implements IPreferencesServic ...@@ -195,13 +194,13 @@ export class PreferencesService extends Disposable implements IPreferencesServic
return this.openOrSwitchSettings(target, resource); return this.openOrSwitchSettings(target, resource);
} }
private openSettings2(): TPromise<IEditor> { private openSettings2(): Thenable<IEditor> {
const input = this.settingsEditor2Input; const input = this.settingsEditor2Input;
return this.editorGroupService.activeGroup.openEditor(input) return this.editorGroupService.activeGroup.openEditor(input)
.then(() => this.editorGroupService.activeGroup.activeControl); .then(() => this.editorGroupService.activeGroup.activeControl);
} }
openGlobalSettings(jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): TPromise<IEditor> { openGlobalSettings(jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): Thenable<IEditor> {
jsonEditor = typeof jsonEditor === 'undefined' ? jsonEditor = typeof jsonEditor === 'undefined' ?
this.configurationService.getValue('workbench.settings.editor') === 'json' : this.configurationService.getValue('workbench.settings.editor') === 'json' :
jsonEditor; jsonEditor;
...@@ -211,14 +210,14 @@ export class PreferencesService extends Disposable implements IPreferencesServic ...@@ -211,14 +210,14 @@ export class PreferencesService extends Disposable implements IPreferencesServic
this.openOrSwitchSettings2(ConfigurationTarget.USER, undefined, options, group); this.openOrSwitchSettings2(ConfigurationTarget.USER, undefined, options, group);
} }
openWorkspaceSettings(jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): TPromise<IEditor> { openWorkspaceSettings(jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): Thenable<IEditor> {
jsonEditor = typeof jsonEditor === 'undefined' ? jsonEditor = typeof jsonEditor === 'undefined' ?
this.configurationService.getValue('workbench.settings.editor') === 'json' : this.configurationService.getValue('workbench.settings.editor') === 'json' :
jsonEditor; jsonEditor;
if (this.contextService.getWorkbenchState() === WorkbenchState.EMPTY) { if (this.contextService.getWorkbenchState() === WorkbenchState.EMPTY) {
this.notificationService.info(nls.localize('openFolderFirst', "Open a folder first to create workspace settings")); this.notificationService.info(nls.localize('openFolderFirst', "Open a folder first to create workspace settings"));
return TPromise.as(null); return Promise.resolve(null);
} }
return jsonEditor ? return jsonEditor ?
...@@ -226,7 +225,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic ...@@ -226,7 +225,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
this.openOrSwitchSettings2(ConfigurationTarget.WORKSPACE, undefined, options, group); this.openOrSwitchSettings2(ConfigurationTarget.WORKSPACE, undefined, options, group);
} }
openFolderSettings(folder: URI, jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): TPromise<IEditor> { openFolderSettings(folder: URI, jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): Thenable<IEditor> {
jsonEditor = typeof jsonEditor === 'undefined' ? jsonEditor = typeof jsonEditor === 'undefined' ?
this.configurationService.getValue('workbench.settings.editor') === 'json' : this.configurationService.getValue('workbench.settings.editor') === 'json' :
jsonEditor; jsonEditor;
...@@ -236,7 +235,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic ...@@ -236,7 +235,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
this.openOrSwitchSettings2(ConfigurationTarget.WORKSPACE_FOLDER, folder, options, group); this.openOrSwitchSettings2(ConfigurationTarget.WORKSPACE_FOLDER, folder, options, group);
} }
switchSettings(target: ConfigurationTarget, resource: URI, jsonEditor?: boolean): TPromise<void> { switchSettings(target: ConfigurationTarget, resource: URI, jsonEditor?: boolean): Thenable<void> {
if (!jsonEditor) { if (!jsonEditor) {
return this.doOpenSettings2(target, resource).then(() => null); return this.doOpenSettings2(target, resource).then(() => null);
} }
...@@ -249,7 +248,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic ...@@ -249,7 +248,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
} }
} }
openGlobalKeybindingSettings(textual: boolean): TPromise<void> { openGlobalKeybindingSettings(textual: boolean): Thenable<void> {
/* __GDPR__ /* __GDPR__
"openKeybindings" : { "openKeybindings" : {
"textual" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true } "textual" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
...@@ -266,7 +265,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic ...@@ -266,7 +265,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
if (openDefaultKeybindings) { if (openDefaultKeybindings) {
const activeEditorGroup = this.editorGroupService.activeGroup; const activeEditorGroup = this.editorGroupService.activeGroup;
const sideEditorGroup = this.editorGroupService.addGroup(activeEditorGroup.id, GroupDirection.RIGHT); const sideEditorGroup = this.editorGroupService.addGroup(activeEditorGroup.id, GroupDirection.RIGHT);
return TPromise.join([ return Promise.all([
this.editorService.openEditor({ resource: this.defaultKeybindingsResource, options: { pinned: true, preserveFocus: true }, label: nls.localize('defaultKeybindings', "Default Keybindings"), description: '' }), this.editorService.openEditor({ resource: this.defaultKeybindingsResource, options: { pinned: true, preserveFocus: true }, label: nls.localize('defaultKeybindings', "Default Keybindings"), description: '' }),
this.editorService.openEditor({ resource: editableKeybindings, options: { pinned: true } }, sideEditorGroup.id) this.editorService.openEditor({ resource: editableKeybindings, options: { pinned: true } }, sideEditorGroup.id)
]).then(editors => void 0); ]).then(editors => void 0);
...@@ -279,7 +278,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic ...@@ -279,7 +278,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
return this.editorService.openEditor(this.instantiationService.createInstance(KeybindingsEditorInput), { pinned: true }).then(() => null); return this.editorService.openEditor(this.instantiationService.createInstance(KeybindingsEditorInput), { pinned: true }).then(() => null);
} }
openDefaultKeybindingsFile(): TPromise<IEditor> { openDefaultKeybindingsFile(): Thenable<IEditor> {
return this.editorService.openEditor({ resource: this.defaultKeybindingsResource, label: nls.localize('defaultKeybindings', "Default Keybindings") }); return this.editorService.openEditor({ resource: this.defaultKeybindingsResource, label: nls.localize('defaultKeybindings', "Default Keybindings") });
} }
...@@ -301,7 +300,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic ...@@ -301,7 +300,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
})); }));
} }
private openOrSwitchSettings(configurationTarget: ConfigurationTarget, resource: URI, options?: ISettingsEditorOptions, group: IEditorGroup = this.editorGroupService.activeGroup): TPromise<IEditor> { private openOrSwitchSettings(configurationTarget: ConfigurationTarget, resource: URI, options?: ISettingsEditorOptions, group: IEditorGroup = this.editorGroupService.activeGroup): Thenable<IEditor> {
const editorInput = this.getActiveSettingsEditorInput(group); const editorInput = this.getActiveSettingsEditorInput(group);
if (editorInput && editorInput.master.getResource().fsPath !== resource.fsPath) { if (editorInput && editorInput.master.getResource().fsPath !== resource.fsPath) {
return this.doSwitchSettings(configurationTarget, resource, editorInput, group, options); return this.doSwitchSettings(configurationTarget, resource, editorInput, group, options);
...@@ -309,11 +308,11 @@ export class PreferencesService extends Disposable implements IPreferencesServic ...@@ -309,11 +308,11 @@ export class PreferencesService extends Disposable implements IPreferencesServic
return this.doOpenSettings(configurationTarget, resource, options, group); return this.doOpenSettings(configurationTarget, resource, options, group);
} }
private openOrSwitchSettings2(configurationTarget: ConfigurationTarget, folderUri?: URI, options?: ISettingsEditorOptions, group: IEditorGroup = this.editorGroupService.activeGroup): TPromise<IEditor> { private openOrSwitchSettings2(configurationTarget: ConfigurationTarget, folderUri?: URI, options?: ISettingsEditorOptions, group: IEditorGroup = this.editorGroupService.activeGroup): Thenable<IEditor> {
return this.doOpenSettings2(configurationTarget, folderUri, options, group); return this.doOpenSettings2(configurationTarget, folderUri, options, group);
} }
private doOpenSettings(configurationTarget: ConfigurationTarget, resource: URI, options?: ISettingsEditorOptions, group?: IEditorGroup): TPromise<IEditor> { private doOpenSettings(configurationTarget: ConfigurationTarget, resource: URI, options?: ISettingsEditorOptions, group?: IEditorGroup): Thenable<IEditor> {
const openDefaultSettings = !!this.configurationService.getValue(DEFAULT_SETTINGS_EDITOR_SETTING); const openDefaultSettings = !!this.configurationService.getValue(DEFAULT_SETTINGS_EDITOR_SETTING);
return this.getOrCreateEditableSettingsEditorInput(configurationTarget, resource) return this.getOrCreateEditableSettingsEditorInput(configurationTarget, resource)
.then(editableSettingsEditorInput => { .then(editableSettingsEditorInput => {
...@@ -337,7 +336,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic ...@@ -337,7 +336,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
return this.instantiationService.createInstance(Settings2EditorModel, this.getDefaultSettings(ConfigurationTarget.USER)); return this.instantiationService.createInstance(Settings2EditorModel, this.getDefaultSettings(ConfigurationTarget.USER));
} }
private doOpenSettings2(target: ConfigurationTarget, folderUri: URI | undefined, options?: IEditorOptions, group?: IEditorGroup): TPromise<IEditor> { private doOpenSettings2(target: ConfigurationTarget, folderUri: URI | undefined, options?: IEditorOptions, group?: IEditorGroup): Thenable<IEditor> {
const input = this.settingsEditor2Input; const input = this.settingsEditor2Input;
const settingsOptions: ISettingsEditorOptions = { const settingsOptions: ISettingsEditorOptions = {
...options, ...options,
...@@ -348,7 +347,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic ...@@ -348,7 +347,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
return this.editorService.openEditor(input, SettingsEditorOptions.create(settingsOptions), group); return this.editorService.openEditor(input, SettingsEditorOptions.create(settingsOptions), group);
} }
private doSwitchSettings(target: ConfigurationTarget, resource: URI, input: PreferencesEditorInput, group: IEditorGroup, options?: ISettingsEditorOptions): TPromise<IEditor> { private doSwitchSettings(target: ConfigurationTarget, resource: URI, input: PreferencesEditorInput, group: IEditorGroup, options?: ISettingsEditorOptions): Thenable<IEditor> {
return this.getOrCreateEditableSettingsEditorInput(target, this.getEditableSettingsURI(target, resource)) return this.getOrCreateEditableSettingsEditorInput(target, this.getEditableSettingsURI(target, resource))
.then(toInput => { .then(toInput => {
return group.openEditor(input).then(() => { return group.openEditor(input).then(() => {
...@@ -423,12 +422,12 @@ export class PreferencesService extends Disposable implements IPreferencesServic ...@@ -423,12 +422,12 @@ export class PreferencesService extends Disposable implements IPreferencesServic
return target === ConfigurationTarget.WORKSPACE_FOLDER ? nls.localize('folderSettingsName', "{0} (Folder Settings)", name) : name; return target === ConfigurationTarget.WORKSPACE_FOLDER ? nls.localize('folderSettingsName', "{0} (Folder Settings)", name) : name;
} }
private getOrCreateEditableSettingsEditorInput(target: ConfigurationTarget, resource: URI): TPromise<EditorInput> { private getOrCreateEditableSettingsEditorInput(target: ConfigurationTarget, resource: URI): Thenable<EditorInput> {
return this.createSettingsIfNotExists(target, resource) return this.createSettingsIfNotExists(target, resource)
.then(() => <EditorInput>this.editorService.createInput({ resource })); .then(() => <EditorInput>this.editorService.createInput({ resource }));
} }
private createEditableSettingsEditorModel(configurationTarget: ConfigurationTarget, resource: URI): TPromise<SettingsEditorModel> { private createEditableSettingsEditorModel(configurationTarget: ConfigurationTarget, resource: URI): Thenable<SettingsEditorModel> {
const settingsUri = this.getEditableSettingsURI(configurationTarget, resource); const settingsUri = this.getEditableSettingsURI(configurationTarget, resource);
if (settingsUri) { if (settingsUri) {
const workspace = this.contextService.getWorkspace(); const workspace = this.contextService.getWorkspace();
...@@ -439,10 +438,10 @@ export class PreferencesService extends Disposable implements IPreferencesServic ...@@ -439,10 +438,10 @@ export class PreferencesService extends Disposable implements IPreferencesServic
return this.textModelResolverService.createModelReference(settingsUri) return this.textModelResolverService.createModelReference(settingsUri)
.then(reference => this.instantiationService.createInstance(SettingsEditorModel, reference, configurationTarget)); .then(reference => this.instantiationService.createInstance(SettingsEditorModel, reference, configurationTarget));
} }
return TPromise.wrap<SettingsEditorModel>(null); return Promise.resolve<SettingsEditorModel>(null);
} }
private createDefaultSettingsEditorModel(defaultSettingsUri: URI): TPromise<DefaultSettingsEditorModel> { private createDefaultSettingsEditorModel(defaultSettingsUri: URI): Thenable<DefaultSettingsEditorModel> {
return this.textModelResolverService.createModelReference(defaultSettingsUri) return this.textModelResolverService.createModelReference(defaultSettingsUri)
.then(reference => { .then(reference => {
const target = this.getConfigurationTargetFromDefaultSettingsResource(defaultSettingsUri); const target = this.getConfigurationTargetFromDefaultSettingsResource(defaultSettingsUri);
...@@ -486,7 +485,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic ...@@ -486,7 +485,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
return null; return null;
} }
private createSettingsIfNotExists(target: ConfigurationTarget, resource: URI): TPromise<void> { private createSettingsIfNotExists(target: ConfigurationTarget, resource: URI): Thenable<void> {
if (this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE && target === ConfigurationTarget.WORKSPACE) { if (this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE && target === ConfigurationTarget.WORKSPACE) {
return this.fileService.resolveContent(this.contextService.getWorkspace().configuration) return this.fileService.resolveContent(this.contextService.getWorkspace().configuration)
.then(content => { .then(content => {
...@@ -499,15 +498,15 @@ export class PreferencesService extends Disposable implements IPreferencesServic ...@@ -499,15 +498,15 @@ export class PreferencesService extends Disposable implements IPreferencesServic
return this.createIfNotExists(resource, emptyEditableSettingsContent).then(() => { }); return this.createIfNotExists(resource, emptyEditableSettingsContent).then(() => { });
} }
private createIfNotExists(resource: URI, contents: string): TPromise<any> { private createIfNotExists(resource: URI, contents: string): Thenable<any> {
return this.fileService.resolveContent(resource, { acceptTextOnly: true }).then(null, error => { return this.fileService.resolveContent(resource, { acceptTextOnly: true }).then(null, error => {
if ((<FileOperationError>error).fileOperationResult === FileOperationResult.FILE_NOT_FOUND) { if ((<FileOperationError>error).fileOperationResult === FileOperationResult.FILE_NOT_FOUND) {
return this.fileService.updateContent(resource, contents).then(null, error => { return this.fileService.updateContent(resource, contents).then(null, error => {
return TPromise.wrapError(new Error(nls.localize('fail.createSettings', "Unable to create '{0}' ({1}).", this.labelService.getUriLabel(resource, { relative: true }), error))); return Promise.reject(new Error(nls.localize('fail.createSettings', "Unable to create '{0}' ({1}).", this.labelService.getUriLabel(resource, { relative: true }), error)));
}); });
} }
return TPromise.wrapError(error); return Promise.reject(error);
}); });
} }
...@@ -527,7 +526,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic ...@@ -527,7 +526,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
]; ];
} }
private getPosition(language: string, settingsModel: IPreferencesEditorModel<ISetting>, codeEditor: ICodeEditor): TPromise<IPosition> { private getPosition(language: string, settingsModel: IPreferencesEditorModel<ISetting>, codeEditor: ICodeEditor): Thenable<IPosition> {
const languageKey = `[${language}]`; const languageKey = `[${language}]`;
let setting = settingsModel.getPreference(languageKey); let setting = settingsModel.getPreference(languageKey);
const model = codeEditor.getModel(); const model = codeEditor.getModel();
...@@ -544,9 +543,9 @@ export class PreferencesService extends Disposable implements IPreferencesServic ...@@ -544,9 +543,9 @@ export class PreferencesService extends Disposable implements IPreferencesServic
} }
const editOperation = EditOperation.insert(new Position(lastSetting.valueRange.endLineNumber, lastSetting.valueRange.endColumn), content); const editOperation = EditOperation.insert(new Position(lastSetting.valueRange.endLineNumber, lastSetting.valueRange.endColumn), content);
model.pushEditOperations([], [editOperation], () => []); model.pushEditOperations([], [editOperation], () => []);
return TPromise.as({ lineNumber: lastSetting.valueRange.endLineNumber + 1, column: model.getLineMaxColumn(lastSetting.valueRange.endLineNumber + 1) }); return Promise.resolve({ lineNumber: lastSetting.valueRange.endLineNumber + 1, column: model.getLineMaxColumn(lastSetting.valueRange.endLineNumber + 1) });
} }
return TPromise.as({ lineNumber: setting.valueRange.startLineNumber, column: setting.valueRange.startColumn + 1 }); return Promise.resolve({ lineNumber: setting.valueRange.startLineNumber, column: setting.valueRange.startColumn + 1 });
} }
return this.configurationService.updateValue(languageKey, {}, ConfigurationTarget.USER) return this.configurationService.updateValue(languageKey, {}, ConfigurationTarget.USER)
.then(() => { .then(() => {
......
...@@ -3,23 +3,22 @@ ...@@ -3,23 +3,22 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { IStringDictionary } from 'vs/base/common/collections';
import { Event } from 'vs/base/common/event';
import { join } from 'vs/base/common/paths';
import { URI } from 'vs/base/common/uri'; import { URI } from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IEditorOptions } from 'vs/platform/editor/common/editor';
import { IEditor, EditorOptions } from 'vs/workbench/common/editor';
import { ITextModel } from 'vs/editor/common/model';
import { IRange } from 'vs/editor/common/core/range'; import { IRange } from 'vs/editor/common/core/range';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { ITextModel } from 'vs/editor/common/model';
import { join } from 'vs/base/common/paths'; import { localize } from 'vs/nls';
import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration'; import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
import { Event } from 'vs/base/common/event'; import { ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
import { IStringDictionary } from 'vs/base/common/collections'; import { IEditorOptions } from 'vs/platform/editor/common/editor';
import { ILocalExtension } from 'vs/platform/extensionManagement/common/extensionManagement'; import { ILocalExtension } from 'vs/platform/extensionManagement/common/extensionManagement';
import { localize } from 'vs/nls'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { EditorOptions, IEditor } from 'vs/workbench/common/editor';
import { IEditorGroup } from 'vs/workbench/services/group/common/editorGroupsService'; import { IEditorGroup } from 'vs/workbench/services/group/common/editorGroupsService';
import { Settings2EditorModel } from 'vs/workbench/services/preferences/common/preferencesModels'; import { Settings2EditorModel } from 'vs/workbench/services/preferences/common/preferencesModels';
import { ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
export enum SettingValueType { export enum SettingValueType {
Null = 'null', Null = 'null',
...@@ -202,18 +201,18 @@ export interface IPreferencesService { ...@@ -202,18 +201,18 @@ export interface IPreferencesService {
workspaceSettingsResource: URI; workspaceSettingsResource: URI;
getFolderSettingsResource(resource: URI): URI; getFolderSettingsResource(resource: URI): URI;
resolveModel(uri: URI): TPromise<ITextModel>; resolveModel(uri: URI): Thenable<ITextModel>;
createPreferencesEditorModel<T>(uri: URI): TPromise<IPreferencesEditorModel<T>>; createPreferencesEditorModel<T>(uri: URI): Thenable<IPreferencesEditorModel<T>>;
createSettings2EditorModel(): Settings2EditorModel; // TODO createSettings2EditorModel(): Settings2EditorModel; // TODO
openRawDefaultSettings(): TPromise<IEditor>; openRawDefaultSettings(): Thenable<IEditor>;
openSettings(jsonEditor?: boolean): TPromise<IEditor>; openSettings(jsonEditor?: boolean): Thenable<IEditor>;
openGlobalSettings(jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): TPromise<IEditor>; openGlobalSettings(jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): Thenable<IEditor>;
openWorkspaceSettings(jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): TPromise<IEditor>; openWorkspaceSettings(jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): Thenable<IEditor>;
openFolderSettings(folder: URI, jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): TPromise<IEditor>; openFolderSettings(folder: URI, jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): Thenable<IEditor>;
switchSettings(target: ConfigurationTarget, resource: URI, jsonEditor?: boolean): TPromise<void>; switchSettings(target: ConfigurationTarget, resource: URI, jsonEditor?: boolean): Thenable<void>;
openGlobalKeybindingSettings(textual: boolean): TPromise<void>; openGlobalKeybindingSettings(textual: boolean): Thenable<void>;
openDefaultKeybindingsFile(): TPromise<IEditor>; openDefaultKeybindingsFile(): Thenable<IEditor>;
configureSettingsForLanguage(language: string): void; configureSettingsForLanguage(language: string): void;
} }
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
import { OS } from 'vs/base/common/platform'; import { OS } from 'vs/base/common/platform';
import { URI } from 'vs/base/common/uri'; import { URI } from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base';
import { ITextModelService } from 'vs/editor/common/services/resolverService'; import { ITextModelService } from 'vs/editor/common/services/resolverService';
import * as nls from 'vs/nls'; import * as nls from 'vs/nls';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
...@@ -70,8 +69,8 @@ export class KeybindingsEditorInput extends EditorInput { ...@@ -70,8 +69,8 @@ export class KeybindingsEditorInput extends EditorInput {
return nls.localize('keybindingsInputName', "Keyboard Shortcuts"); return nls.localize('keybindingsInputName', "Keyboard Shortcuts");
} }
resolve(): TPromise<KeybindingsEditorModel> { resolve(): Promise<KeybindingsEditorModel> {
return TPromise.as(this.keybindingsModel); return Promise.resolve(this.keybindingsModel);
} }
matches(otherInput: any): boolean { matches(otherInput: any): boolean {
...@@ -104,8 +103,8 @@ export class SettingsEditor2Input extends EditorInput { ...@@ -104,8 +103,8 @@ export class SettingsEditor2Input extends EditorInput {
return nls.localize('settingsEditor2InputName', "Settings"); return nls.localize('settingsEditor2InputName', "Settings");
} }
resolve(): TPromise<Settings2EditorModel> { resolve(): Promise<Settings2EditorModel> {
return TPromise.as(this._settingsModel); return Promise.resolve(this._settingsModel);
} }
public getResource(): URI { public getResource(): URI {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册