提交 94edf19b 编写于 作者: R Rob Lourens

Settings editor - filter result list when a TOC entry is clicked during search

上级 b31c338c
......@@ -243,7 +243,11 @@ export class SettingsEditor2 extends BaseEditor {
});
this._register(this.tocTree.onDidChangeSelection(e => {
if (this.settingsTreeModel) {
if (this.searchResultModel) {
const element = e.selection[0];
this.viewState.filterToCategory = element;
this.refreshTreeAndMaintainFocus();
} else if (this.settingsTreeModel) {
const element = e.selection[0];
const currentSelection = this.settingsTree.getSelection()[0];
const isEqualOrParent = (element: SettingsTreeElement, candidate: SettingsTreeElement) => {
......@@ -550,6 +554,7 @@ export class SettingsEditor2 extends BaseEditor {
this.searchResultModel = null;
this.tocTreeModel.currentSearchModel = null;
this.viewState.filterToCategory = null;
this.tocTree.refresh();
this.toggleSearchMode();
this.settingsTree.setInput(this.settingsTreeModel.root);
......
......@@ -359,6 +359,7 @@ function trimCategoryForGroup(category: string, groupId: string): string {
export interface ISettingsEditorViewState {
settingsTarget: SettingsTarget;
showConfiguredOnly?: boolean;
filterToCategory?: SettingsTreeGroupElement;
}
interface IDisposableTemplate {
......@@ -674,7 +675,13 @@ export class SettingsTreeFilter implements IFilter {
) { }
isVisible(tree: ITree, element: SettingsTreeElement): boolean {
if (this.viewState.showConfiguredOnly && element instanceof SettingsTreeSettingElement) {
if (this.viewState.filterToCategory && element instanceof SettingsTreeSettingElement) {
if (!this.settingContainedInGroup(element.setting, this.viewState.filterToCategory)) {
return false;
}
}
if (element instanceof SettingsTreeSettingElement && this.viewState.showConfiguredOnly) {
return element.isConfigured;
}
......@@ -685,6 +692,18 @@ export class SettingsTreeFilter implements IFilter {
return true;
}
private settingContainedInGroup(setting: ISetting, group: SettingsTreeGroupElement): boolean {
return group.children.some(child => {
if (child instanceof SettingsTreeGroupElement) {
return this.settingContainedInGroup(setting, child);
} else if (child instanceof SettingsTreeSettingElement) {
return child.setting.key === setting.key;
} else {
return false;
}
});
}
private groupHasConfiguredSetting(element: SettingsTreeGroupElement): boolean {
for (let child of element.children) {
if (child instanceof SettingsTreeSettingElement) {
......
......@@ -114,11 +114,6 @@ interface ITOCEntryTemplate {
}
export class TOCRenderer implements IRenderer {
constructor(
@IConfigurationService private configService: IConfigurationService
) {
}
getHeight(tree: ITree, element: SettingsTreeElement): number {
return 22;
}
......@@ -138,10 +133,7 @@ export class TOCRenderer implements IRenderer {
`${element.label} (${(<any>element).count})` :
element.label;
if (this.configService.getValue('workbench.settings.settingsSearchTocBehavior') === 'show') {
DOM.toggleClass(template.element, 'no-results', (<any>element).count === 0);
}
DOM.toggleClass(template.element, 'no-results', (<any>element).count === 0);
template.element.textContent = label;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册