Skip to content

Commit

Permalink
Fix #50632
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens committed May 30, 2018
1 parent 5fad13a commit 0332c70
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions src/vs/workbench/parts/preferences/browser/settingsEditor2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export class SettingsEditor2 extends BaseEditor {
private delayedFilterLogging: Delayer<void>;
private localSearchDelayer: Delayer<void>;
private remoteSearchThrottle: ThrottledDelayer<void>;
private searchInProgress: TPromise<void>;

private pendingSettingModifiedReport: { key: string, value: any };

Expand Down Expand Up @@ -424,14 +425,18 @@ export class SettingsEditor2 extends BaseEditor {

private triggerSearch(query: string): TPromise<void> {
if (query) {
return TPromise.join([
return this.searchInProgress = TPromise.join([
this.localSearchDelayer.trigger(() => this.localFilterPreferences(query)),
this.remoteSearchThrottle.trigger(() => this.remoteSearchPreferences(query), 500)
]) as TPromise;
]).then(() => {
this.searchInProgress = null;
});
} else {
// When clearing the input, update immediately to clear it
this.localSearchDelayer.cancel();
this.remoteSearchThrottle.cancel();
if (this.searchInProgress && this.searchInProgress.cancel) {
this.searchInProgress.cancel();
}

this.searchResultModel = null;
this.settingsTree.setInput(this.defaultSettingsEditorModel);
Expand Down Expand Up @@ -495,15 +500,25 @@ export class SettingsEditor2 extends BaseEditor {
private filterOrSearchPreferences(query: string, type: SearchResultIdx, searchProvider: ISearchProvider): TPromise<void> {
const filterPs: TPromise<ISearchResult>[] = [this._filterOrSearchPreferencesModel(query, this.defaultSettingsEditorModel, searchProvider)];

return TPromise.join(filterPs).then(results => {
const [result] = results;
if (!this.searchResultModel) {
this.searchResultModel = new SearchResultModel();
this.settingsTree.setInput(this.searchResultModel);
}
let isCanceled = false;
return new TPromise(resolve => {
return TPromise.join(filterPs).then(results => {
if (isCanceled) {
// Handle cancellation like this because cancellation is lost inside the search provider due to async/await
return null;
}

const [result] = results;
if (!this.searchResultModel) {
this.searchResultModel = new SearchResultModel();
this.settingsTree.setInput(this.searchResultModel);
}

this.searchResultModel.setResult(type, result);
return this.refreshTreeAndMaintainFocus();
this.searchResultModel.setResult(type, result);
resolve(this.refreshTreeAndMaintainFocus());
});
}, () => {
isCanceled = true;
});
}

Expand Down

0 comments on commit 0332c70

Please sign in to comment.