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