提交 5190e300 编写于 作者: R Rob Lourens

Fix #56625 - parse setting name from JSON line

And some other fixes
上级 277fe3d3
......@@ -76,7 +76,7 @@ export class SettingsEditor2 extends BaseEditor {
private delayedFilterLogging: Delayer<void>;
private localSearchDelayer: Delayer<void>;
private remoteSearchThrottle: ThrottledDelayer<void>;
private searchCancelToken: CancellationTokenSource;
private searchInProgress: CancellationTokenSource;
private delayRefreshOnLayout: Delayer<void>;
private lastLayedoutWidth: number;
......@@ -747,6 +747,11 @@ export class SettingsEditor2 extends BaseEditor {
});
}
private parseSettingFromJSON(query: string): string {
const match = query.match(/"([a-zA-Z.]+)": /);
return match && match[1];
}
private triggerSearch(query: string): TPromise<void> {
this.viewState.tagFilters = new Set<string>();
if (query) {
......@@ -762,14 +767,16 @@ export class SettingsEditor2 extends BaseEditor {
query = query.trim();
if (query && query !== '@') {
this.searchCancelToken = new CancellationTokenSource();
query = this.parseSettingFromJSON(query) || query;
this.searchInProgress = new CancellationTokenSource();
return TPromise.join([
this.localSearchDelayer.trigger(() => this.localFilterPreferences(query, this.searchCancelToken.token)),
this.remoteSearchThrottle.trigger(() => this.remoteSearchPreferences(query, this.searchCancelToken.token), 500)
this.localSearchDelayer.trigger(() => this.searchInProgress ? this.localFilterPreferences(query, this.searchInProgress.token) : TPromise.wrap(null)),
this.remoteSearchThrottle.trigger(() => this.searchInProgress ? this.remoteSearchPreferences(query, this.searchInProgress.token) : TPromise.wrap(null), 500)
]).then(() => {
if (this.searchCancelToken) {
this.searchCancelToken.dispose();
this.searchCancelToken = null;
if (this.searchInProgress) {
this.searchInProgress.dispose();
this.searchInProgress = null;
}
});
} else {
......@@ -781,10 +788,10 @@ export class SettingsEditor2 extends BaseEditor {
this.localSearchDelayer.cancel();
this.remoteSearchThrottle.cancel();
if (this.searchCancelToken) {
this.searchCancelToken.cancel();
this.searchCancelToken.dispose();
this.searchCancelToken = null;
if (this.searchInProgress) {
this.searchInProgress.cancel();
this.searchInProgress.dispose();
this.searchInProgress = null;
}
this.viewState.filterToCategory = null;
......
......@@ -429,7 +429,7 @@ export class SearchResultModel extends SettingsTreeModel {
settings: this.getFlatSettings()
});
if (this.newExtensionSearchResults) {
if (this.newExtensionSearchResults && this.newExtensionSearchResults.filterMatches.length) {
const newExtElement = new SettingsTreeNewExtensionsElement();
newExtElement.parent = this._root;
newExtElement.id = 'newExtensions';
......
......@@ -49,15 +49,21 @@ export class TOCTreeModel {
}
private updateGroupCount(group: SettingsTreeGroupElement): void {
group.count = this._currentSearchModel ?
this.getSearchResultChildrenCount(group) :
undefined;
group.children.forEach(child => {
if (child instanceof SettingsTreeGroupElement) {
this.updateGroupCount(child);
}
});
if (this._currentSearchModel) {
const childCount = group.children
.filter(child => child instanceof SettingsTreeGroupElement)
.reduce((acc, cur) => acc + (<SettingsTreeGroupElement>cur).count, 0);
group.count = childCount + this.getSearchResultChildrenCount(group);
} else {
group.count = undefined;
}
}
private getSearchResultChildrenCount(group: SettingsTreeGroupElement): number {
......@@ -70,8 +76,6 @@ export class TOCTreeModel {
return group.children.some(child => {
if (child instanceof SettingsTreeSettingElement) {
return child.setting.key === setting.key && child.matchesAllTags(this.viewState.tagFilters);
} else if (child instanceof SettingsTreeGroupElement) {
return this.groupContainsSetting(child, setting);
} else {
return false;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册