@theia/preferences 1.53.0-next.4 → 1.53.0-next.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +81 -81
  2. package/lib/browser/preference-tree-model.d.ts.map +1 -1
  3. package/lib/browser/preference-tree-model.js +5 -2
  4. package/lib/browser/preference-tree-model.js.map +1 -1
  5. package/lib/browser/util/preference-layout.d.ts.map +1 -1
  6. package/lib/browser/util/preference-layout.js +4 -0
  7. package/lib/browser/util/preference-layout.js.map +1 -1
  8. package/lib/browser/util/preference-tree-generator.d.ts +14 -2
  9. package/lib/browser/util/preference-tree-generator.d.ts.map +1 -1
  10. package/lib/browser/util/preference-tree-generator.js +89 -26
  11. package/lib/browser/util/preference-tree-generator.js.map +1 -1
  12. package/lib/browser/util/preference-tree-label-provider.d.ts.map +1 -1
  13. package/lib/browser/util/preference-tree-label-provider.js +4 -11
  14. package/lib/browser/util/preference-tree-label-provider.js.map +1 -1
  15. package/lib/browser/util/preference-types.d.ts +4 -2
  16. package/lib/browser/util/preference-types.d.ts.map +1 -1
  17. package/lib/browser/util/preference-types.js.map +1 -1
  18. package/lib/browser/views/preference-tree-widget.d.ts +2 -0
  19. package/lib/browser/views/preference-tree-widget.d.ts.map +1 -1
  20. package/lib/browser/views/preference-tree-widget.js +10 -1
  21. package/lib/browser/views/preference-tree-widget.js.map +1 -1
  22. package/package.json +9 -9
  23. package/src/browser/abstract-resource-preference-provider.spec.ts +95 -95
  24. package/src/browser/abstract-resource-preference-provider.ts +232 -232
  25. package/src/browser/folder-preference-provider.ts +58 -58
  26. package/src/browser/folders-preferences-provider.ts +244 -244
  27. package/src/browser/index.ts +23 -23
  28. package/src/browser/monaco-jsonc-editor.ts +67 -67
  29. package/src/browser/package.spec.ts +28 -28
  30. package/src/browser/preference-bindings.ts +65 -65
  31. package/src/browser/preference-frontend-contribution.ts +38 -38
  32. package/src/browser/preference-frontend-module.ts +66 -66
  33. package/src/browser/preference-open-handler.ts +53 -53
  34. package/src/browser/preference-transaction-manager.ts +287 -287
  35. package/src/browser/preference-tree-model.ts +260 -257
  36. package/src/browser/preferences-contribution.ts +263 -263
  37. package/src/browser/preferences-json-schema-contribution.ts +86 -86
  38. package/src/browser/preferences-monaco-contribution.ts +27 -27
  39. package/src/browser/section-preference-provider.ts +83 -83
  40. package/src/browser/style/index.css +506 -506
  41. package/src/browser/style/preference-array.css +94 -94
  42. package/src/browser/style/preference-context-menu.css +74 -74
  43. package/src/browser/style/preference-file.css +31 -31
  44. package/src/browser/style/preference-object.css +49 -49
  45. package/src/browser/style/search-input.css +66 -66
  46. package/src/browser/user-configs-preference-provider.ts +127 -127
  47. package/src/browser/user-preference-provider.ts +35 -35
  48. package/src/browser/util/preference-layout.ts +381 -377
  49. package/src/browser/util/preference-scope-command-manager.ts +75 -75
  50. package/src/browser/util/preference-tree-generator.ts +260 -190
  51. package/src/browser/util/preference-tree-label-provider.spec.ts +110 -110
  52. package/src/browser/util/preference-tree-label-provider.ts +72 -78
  53. package/src/browser/util/preference-types.ts +177 -175
  54. package/src/browser/views/components/preference-array-input.ts +174 -174
  55. package/src/browser/views/components/preference-boolean-input.ts +69 -69
  56. package/src/browser/views/components/preference-file-input.ts +104 -104
  57. package/src/browser/views/components/preference-json-input.ts +78 -78
  58. package/src/browser/views/components/preference-markdown-renderer.ts +68 -68
  59. package/src/browser/views/components/preference-node-renderer-creator.ts +141 -141
  60. package/src/browser/views/components/preference-node-renderer.ts +477 -477
  61. package/src/browser/views/components/preference-number-input.ts +147 -147
  62. package/src/browser/views/components/preference-select-input.ts +131 -131
  63. package/src/browser/views/components/preference-string-input.ts +76 -76
  64. package/src/browser/views/preference-editor-widget.ts +349 -349
  65. package/src/browser/views/preference-scope-tabbar-widget.tsx +344 -344
  66. package/src/browser/views/preference-searchbar-widget.tsx +183 -183
  67. package/src/browser/views/preference-tree-widget.tsx +102 -93
  68. package/src/browser/views/preference-widget-bindings.ts +102 -102
  69. package/src/browser/views/preference-widget.tsx +118 -118
  70. package/src/browser/workspace-file-preference-provider.ts +100 -100
  71. package/src/browser/workspace-preference-provider.ts +134 -134
  72. package/src/common/cli-preferences.ts +22 -22
  73. package/src/node/preference-backend-module.ts +33 -33
  74. package/src/node/preference-cli-contribution.ts +48 -48
@@ -1,257 +1,260 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2020 Ericsson and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
18
- import {
19
- TreeModelImpl,
20
- TreeWidget,
21
- CompositeTreeNode,
22
- TopDownTreeIterator,
23
- TreeNode,
24
- PreferenceSchemaProvider,
25
- PreferenceDataProperty,
26
- NodeProps,
27
- ExpandableTreeNode,
28
- SelectableTreeNode,
29
- PreferenceService,
30
- } from '@theia/core/lib/browser';
31
- import { Emitter } from '@theia/core';
32
- import { PreferencesSearchbarWidget } from './views/preference-searchbar-widget';
33
- import { PreferenceTreeGenerator } from './util/preference-tree-generator';
34
- import * as fuzzy from '@theia/core/shared/fuzzy';
35
- import { PreferencesScopeTabBar } from './views/preference-scope-tabbar-widget';
36
- import { Preference } from './util/preference-types';
37
- import { Event } from '@theia/core/lib/common';
38
- import { COMMONLY_USED_SECTION_PREFIX } from './util/preference-layout';
39
-
40
- export interface PreferenceTreeNodeProps extends NodeProps {
41
- visibleChildren: number;
42
- isExpansible?: boolean;
43
- }
44
-
45
- export interface PreferenceTreeNodeRow extends Readonly<TreeWidget.NodeRow>, PreferenceTreeNodeProps {
46
- node: Preference.TreeNode;
47
- }
48
- export enum PreferenceFilterChangeSource {
49
- Schema,
50
- Search,
51
- Scope,
52
- }
53
- export interface PreferenceFilterChangeEvent {
54
- source: PreferenceFilterChangeSource
55
- }
56
-
57
- @injectable()
58
- export class PreferenceTreeModel extends TreeModelImpl {
59
-
60
- @inject(PreferenceSchemaProvider) protected readonly schemaProvider: PreferenceSchemaProvider;
61
- @inject(PreferencesSearchbarWidget) protected readonly filterInput: PreferencesSearchbarWidget;
62
- @inject(PreferenceTreeGenerator) protected readonly treeGenerator: PreferenceTreeGenerator;
63
- @inject(PreferencesScopeTabBar) protected readonly scopeTracker: PreferencesScopeTabBar;
64
- @inject(PreferenceService) protected readonly preferenceService: PreferenceService;
65
-
66
- protected readonly onTreeFilterChangedEmitter = new Emitter<PreferenceFilterChangeEvent>();
67
- readonly onFilterChanged = this.onTreeFilterChangedEmitter.event;
68
-
69
- protected lastSearchedFuzzy: string = '';
70
- protected lastSearchedLiteral: string = '';
71
- protected lastSearchedTags: string[] = [];
72
- protected _currentScope: number = Number(Preference.DEFAULT_SCOPE.scope);
73
- protected _isFiltered: boolean = false;
74
- protected _currentRows: Map<string, PreferenceTreeNodeRow> = new Map();
75
- protected _totalVisibleLeaves = 0;
76
-
77
- get currentRows(): Readonly<Map<string, PreferenceTreeNodeRow>> {
78
- return this._currentRows;
79
- }
80
-
81
- get totalVisibleLeaves(): number {
82
- return this._totalVisibleLeaves;
83
- }
84
-
85
- get isFiltered(): boolean {
86
- return this._isFiltered;
87
- }
88
-
89
- get propertyList(): { [key: string]: PreferenceDataProperty; } {
90
- return this.schemaProvider.getCombinedSchema().properties;
91
- }
92
-
93
- get currentScope(): Preference.SelectedScopeDetails {
94
- return this.scopeTracker.currentScope;
95
- }
96
-
97
- get onSchemaChanged(): Event<CompositeTreeNode> {
98
- return this.treeGenerator.onSchemaChanged;
99
- }
100
-
101
- @postConstruct()
102
- protected override init(): void {
103
- this.doInit();
104
- }
105
-
106
- protected async doInit(): Promise<void> {
107
- super.init();
108
- this.toDispose.pushAll([
109
- this.treeGenerator.onSchemaChanged(newTree => this.handleNewSchema(newTree)),
110
- this.scopeTracker.onScopeChanged(scopeDetails => {
111
- this._currentScope = scopeDetails.scope;
112
- this.updateFilteredRows(PreferenceFilterChangeSource.Scope);
113
- }),
114
- this.filterInput.onFilterChanged(newSearchTerm => {
115
- this.lastSearchedTags = Array.from(newSearchTerm.matchAll(/@tag:([^\s]+)/g)).map(match => match[0].slice(5));
116
- const newSearchTermWithoutTags = newSearchTerm.replace(/@tag:[^\s]+/g, '');
117
- this.lastSearchedLiteral = newSearchTermWithoutTags;
118
- this.lastSearchedFuzzy = newSearchTermWithoutTags.replace(/\s/g, '');
119
- this._isFiltered = newSearchTerm.length > 2;
120
- if (this.isFiltered) {
121
- this.expandAll();
122
- } else if (CompositeTreeNode.is(this.root)) {
123
- this.collapseAll(this.root);
124
- }
125
- this.updateFilteredRows(PreferenceFilterChangeSource.Search);
126
- }),
127
- this.onFilterChanged(() => {
128
- this.filterInput.updateResultsCount(this._totalVisibleLeaves);
129
- }),
130
- this.onTreeFilterChangedEmitter,
131
- ]);
132
- await this.preferenceService.ready;
133
- this.handleNewSchema(this.treeGenerator.root);
134
- }
135
-
136
- private handleNewSchema(newRoot: CompositeTreeNode): void {
137
- this.root = newRoot;
138
- if (this.isFiltered) {
139
- this.expandAll();
140
- }
141
- this.updateFilteredRows(PreferenceFilterChangeSource.Schema);
142
- }
143
-
144
- protected updateRows(): void {
145
- const root = this.root;
146
- this._currentRows = new Map();
147
- if (root) {
148
- this._totalVisibleLeaves = 0;
149
- let index = 0;
150
-
151
- for (const node of new TopDownTreeIterator(root, {
152
- pruneCollapsed: false,
153
- pruneSiblings: true
154
- })) {
155
- if (TreeNode.isVisible(node) && Preference.TreeNode.is(node)) {
156
- const { id } = Preference.TreeNode.getGroupAndIdFromNodeId(node.id);
157
- if (CompositeTreeNode.is(node) || this.passesCurrentFilters(node, id)) {
158
- this.updateVisibleChildren(node);
159
-
160
- this._currentRows.set(node.id, {
161
- index: index++,
162
- node,
163
- depth: node.depth,
164
- visibleChildren: 0,
165
- });
166
- }
167
- }
168
- }
169
- }
170
- }
171
-
172
- protected updateFilteredRows(source: PreferenceFilterChangeSource): void {
173
- this.updateRows();
174
- this.onTreeFilterChangedEmitter.fire({ source });
175
- }
176
-
177
- protected passesCurrentFilters(node: Preference.LeafNode, prefID: string): boolean {
178
- if (!this.schemaProvider.isValidInScope(prefID, this._currentScope)) {
179
- return false;
180
- }
181
- if (!this._isFiltered) {
182
- return true;
183
- }
184
- // When filtering, VSCode will render an item that is present in the commonly used section only once but render both its possible parents in the left-hand tree.
185
- // E.g. searching for editor.renderWhitespace will show one item in the main panel, but both 'Commonly Used' and 'Text Editor' in the left tree.
186
- // That seems counterintuitive and introduces a number of special cases, so I prefer to remove the commonly used section entirely when the user searches.
187
- if (node.id.startsWith(COMMONLY_USED_SECTION_PREFIX)) {
188
- return false;
189
- }
190
- if (!this.lastSearchedTags.every(tag => node.preference.data.tags?.includes(tag))) {
191
- return false;
192
- }
193
- return fuzzy.test(this.lastSearchedFuzzy, prefID) // search matches preference name.
194
- // search matches description. Fuzzy isn't ideal here because the score depends on the order of discovery.
195
- || (node.preference.data.description ?? '').includes(this.lastSearchedLiteral);
196
- }
197
-
198
- protected override isVisibleSelectableNode(node: TreeNode): node is SelectableTreeNode {
199
- return CompositeTreeNode.is(node) && !!this._currentRows.get(node.id)?.visibleChildren;
200
- }
201
-
202
- protected updateVisibleChildren(node: TreeNode): void {
203
- if (!CompositeTreeNode.is(node)) {
204
- this._totalVisibleLeaves++;
205
- let nextParent = node.parent?.id && this._currentRows.get(node.parent?.id);
206
- while (nextParent && nextParent.node !== this.root) {
207
- if (nextParent) {
208
- nextParent.visibleChildren += 1;
209
- }
210
- nextParent = nextParent.node.parent?.id && this._currentRows.get(nextParent.node.parent?.id);
211
- if (nextParent) {
212
- nextParent.isExpansible = true;
213
- }
214
- }
215
- }
216
- }
217
-
218
- collapseAllExcept(openNode: TreeNode | undefined): void {
219
- if (ExpandableTreeNode.is(openNode)) {
220
- this.expandNode(openNode);
221
- }
222
- if (CompositeTreeNode.is(this.root)) {
223
- this.root.children.forEach(child => {
224
- if (child !== openNode && ExpandableTreeNode.is(child)) {
225
- this.collapseNode(child);
226
- }
227
- });
228
- }
229
- }
230
-
231
- protected expandAll(): void {
232
- if (CompositeTreeNode.is(this.root)) {
233
- this.root.children.forEach(child => {
234
- if (ExpandableTreeNode.is(child)) {
235
- this.expandNode(child);
236
- }
237
- });
238
- }
239
- }
240
-
241
- getNodeFromPreferenceId(id: string): Preference.TreeNode | undefined {
242
- const node = this.getNode(this.treeGenerator.getNodeId(id));
243
- return node && Preference.TreeNode.is(node) ? node : undefined;
244
- }
245
-
246
- /**
247
- * @returns true if selection changed, false otherwise
248
- */
249
- selectIfNotSelected(node: SelectableTreeNode): boolean {
250
- const currentlySelected = this.selectedNodes[0];
251
- if (node !== currentlySelected) {
252
- this.selectNode(node);
253
- return true;
254
- }
255
- return false;
256
- }
257
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2020 Ericsson and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
18
+ import {
19
+ TreeModelImpl,
20
+ TreeWidget,
21
+ CompositeTreeNode,
22
+ TopDownTreeIterator,
23
+ TreeNode,
24
+ PreferenceSchemaProvider,
25
+ PreferenceDataProperty,
26
+ NodeProps,
27
+ ExpandableTreeNode,
28
+ SelectableTreeNode,
29
+ PreferenceService,
30
+ } from '@theia/core/lib/browser';
31
+ import { Emitter } from '@theia/core';
32
+ import { PreferencesSearchbarWidget } from './views/preference-searchbar-widget';
33
+ import { PreferenceTreeGenerator } from './util/preference-tree-generator';
34
+ import * as fuzzy from '@theia/core/shared/fuzzy';
35
+ import { PreferencesScopeTabBar } from './views/preference-scope-tabbar-widget';
36
+ import { Preference } from './util/preference-types';
37
+ import { Event } from '@theia/core/lib/common';
38
+ import { COMMONLY_USED_SECTION_PREFIX } from './util/preference-layout';
39
+
40
+ export interface PreferenceTreeNodeProps extends NodeProps {
41
+ visibleChildren: number;
42
+ isExpansible?: boolean;
43
+ }
44
+
45
+ export interface PreferenceTreeNodeRow extends Readonly<TreeWidget.NodeRow>, PreferenceTreeNodeProps {
46
+ node: Preference.TreeNode;
47
+ }
48
+ export enum PreferenceFilterChangeSource {
49
+ Schema,
50
+ Search,
51
+ Scope,
52
+ }
53
+ export interface PreferenceFilterChangeEvent {
54
+ source: PreferenceFilterChangeSource
55
+ }
56
+
57
+ @injectable()
58
+ export class PreferenceTreeModel extends TreeModelImpl {
59
+
60
+ @inject(PreferenceSchemaProvider) protected readonly schemaProvider: PreferenceSchemaProvider;
61
+ @inject(PreferencesSearchbarWidget) protected readonly filterInput: PreferencesSearchbarWidget;
62
+ @inject(PreferenceTreeGenerator) protected readonly treeGenerator: PreferenceTreeGenerator;
63
+ @inject(PreferencesScopeTabBar) protected readonly scopeTracker: PreferencesScopeTabBar;
64
+ @inject(PreferenceService) protected readonly preferenceService: PreferenceService;
65
+
66
+ protected readonly onTreeFilterChangedEmitter = new Emitter<PreferenceFilterChangeEvent>();
67
+ readonly onFilterChanged = this.onTreeFilterChangedEmitter.event;
68
+
69
+ protected lastSearchedFuzzy: string = '';
70
+ protected lastSearchedLiteral: string = '';
71
+ protected lastSearchedTags: string[] = [];
72
+ protected _currentScope: number = Number(Preference.DEFAULT_SCOPE.scope);
73
+ protected _isFiltered: boolean = false;
74
+ protected _currentRows: Map<string, PreferenceTreeNodeRow> = new Map();
75
+ protected _totalVisibleLeaves = 0;
76
+
77
+ get currentRows(): Readonly<Map<string, PreferenceTreeNodeRow>> {
78
+ return this._currentRows;
79
+ }
80
+
81
+ get totalVisibleLeaves(): number {
82
+ return this._totalVisibleLeaves;
83
+ }
84
+
85
+ get isFiltered(): boolean {
86
+ return this._isFiltered;
87
+ }
88
+
89
+ get propertyList(): { [key: string]: PreferenceDataProperty; } {
90
+ return this.schemaProvider.getCombinedSchema().properties;
91
+ }
92
+
93
+ get currentScope(): Preference.SelectedScopeDetails {
94
+ return this.scopeTracker.currentScope;
95
+ }
96
+
97
+ get onSchemaChanged(): Event<CompositeTreeNode> {
98
+ return this.treeGenerator.onSchemaChanged;
99
+ }
100
+
101
+ @postConstruct()
102
+ protected override init(): void {
103
+ this.doInit();
104
+ }
105
+
106
+ protected async doInit(): Promise<void> {
107
+ super.init();
108
+ this.toDispose.pushAll([
109
+ this.treeGenerator.onSchemaChanged(newTree => this.handleNewSchema(newTree)),
110
+ this.scopeTracker.onScopeChanged(scopeDetails => {
111
+ this._currentScope = scopeDetails.scope;
112
+ this.updateFilteredRows(PreferenceFilterChangeSource.Scope);
113
+ }),
114
+ this.filterInput.onFilterChanged(newSearchTerm => {
115
+ this.lastSearchedTags = Array.from(newSearchTerm.matchAll(/@tag:([^\s]+)/g)).map(match => match[0].slice(5));
116
+ const newSearchTermWithoutTags = newSearchTerm.replace(/@tag:[^\s]+/g, '');
117
+ this.lastSearchedLiteral = newSearchTermWithoutTags;
118
+ this.lastSearchedFuzzy = newSearchTermWithoutTags.replace(/\s/g, '');
119
+ this._isFiltered = newSearchTerm.length > 2;
120
+ if (this.isFiltered) {
121
+ this.expandAll();
122
+ } else if (CompositeTreeNode.is(this.root)) {
123
+ this.collapseAll(this.root);
124
+ }
125
+ this.updateFilteredRows(PreferenceFilterChangeSource.Search);
126
+ }),
127
+ this.onFilterChanged(() => {
128
+ this.filterInput.updateResultsCount(this._totalVisibleLeaves);
129
+ }),
130
+ this.onTreeFilterChangedEmitter,
131
+ ]);
132
+ await this.preferenceService.ready;
133
+ this.handleNewSchema(this.treeGenerator.root);
134
+ }
135
+
136
+ private handleNewSchema(newRoot: CompositeTreeNode): void {
137
+ this.root = newRoot;
138
+ if (this.isFiltered) {
139
+ this.expandAll();
140
+ }
141
+ this.updateFilteredRows(PreferenceFilterChangeSource.Schema);
142
+ }
143
+
144
+ protected updateRows(): void {
145
+ const root = this.root;
146
+ this._currentRows = new Map();
147
+ if (root) {
148
+ this._totalVisibleLeaves = 0;
149
+ let index = 0;
150
+
151
+ for (const node of new TopDownTreeIterator(root, {
152
+ pruneCollapsed: false,
153
+ pruneSiblings: true
154
+ })) {
155
+ if (TreeNode.isVisible(node) && Preference.TreeNode.is(node)) {
156
+ const { id } = Preference.TreeNode.getGroupAndIdFromNodeId(node.id);
157
+ if (CompositeTreeNode.is(node) || this.passesCurrentFilters(node, id)) {
158
+ this.updateVisibleChildren(node);
159
+
160
+ this._currentRows.set(node.id, {
161
+ index: index++,
162
+ node,
163
+ depth: node.depth,
164
+ visibleChildren: 0,
165
+ });
166
+ }
167
+ }
168
+ }
169
+ }
170
+ }
171
+
172
+ protected updateFilteredRows(source: PreferenceFilterChangeSource): void {
173
+ this.updateRows();
174
+ this.onTreeFilterChangedEmitter.fire({ source });
175
+ }
176
+
177
+ protected passesCurrentFilters(node: Preference.LeafNode, prefID: string): boolean {
178
+ if (!this.schemaProvider.isValidInScope(prefID, this._currentScope)) {
179
+ return false;
180
+ }
181
+ if (!this._isFiltered) {
182
+ return true;
183
+ }
184
+ // When filtering, VSCode will render an item that is present in the commonly used section only once but render both its possible parents in the left-hand tree.
185
+ // E.g. searching for editor.renderWhitespace will show one item in the main panel, but both 'Commonly Used' and 'Text Editor' in the left tree.
186
+ // That seems counterintuitive and introduces a number of special cases, so I prefer to remove the commonly used section entirely when the user searches.
187
+ if (node.id.startsWith(COMMONLY_USED_SECTION_PREFIX)) {
188
+ return false;
189
+ }
190
+ if (!this.lastSearchedTags.every(tag => node.preference.data.tags?.includes(tag))) {
191
+ return false;
192
+ }
193
+ return fuzzy.test(this.lastSearchedFuzzy, prefID) // search matches preference name.
194
+ // search matches description. Fuzzy isn't ideal here because the score depends on the order of discovery.
195
+ || (node.preference.data.description ?? '').includes(this.lastSearchedLiteral);
196
+ }
197
+
198
+ protected override isVisibleSelectableNode(node: TreeNode): node is SelectableTreeNode {
199
+ return CompositeTreeNode.is(node) && !!this._currentRows.get(node.id)?.visibleChildren;
200
+ }
201
+
202
+ protected updateVisibleChildren(node: TreeNode): void {
203
+ if (!CompositeTreeNode.is(node)) {
204
+ this._totalVisibleLeaves++;
205
+ let nextParent = node.parent?.id && this._currentRows.get(node.parent?.id);
206
+ while (nextParent && nextParent.node !== this.root) {
207
+ if (nextParent) {
208
+ nextParent.visibleChildren += 1;
209
+ }
210
+ nextParent = nextParent.node.parent?.id && this._currentRows.get(nextParent.node.parent?.id);
211
+ if (nextParent) {
212
+ nextParent.isExpansible = true;
213
+ }
214
+ }
215
+ }
216
+ }
217
+
218
+ collapseAllExcept(openNode: TreeNode | undefined): void {
219
+ const openNodes: TreeNode[] = [];
220
+ while (ExpandableTreeNode.is(openNode)) {
221
+ openNodes.push(openNode);
222
+ this.expandNode(openNode);
223
+ openNode = openNode.parent;
224
+ }
225
+ if (CompositeTreeNode.is(this.root)) {
226
+ this.root.children.forEach(child => {
227
+ if (!openNodes.includes(child) && ExpandableTreeNode.is(child)) {
228
+ this.collapseNode(child);
229
+ }
230
+ });
231
+ }
232
+ }
233
+
234
+ protected expandAll(): void {
235
+ if (CompositeTreeNode.is(this.root)) {
236
+ this.root.children.forEach(child => {
237
+ if (ExpandableTreeNode.is(child)) {
238
+ this.expandNode(child);
239
+ }
240
+ });
241
+ }
242
+ }
243
+
244
+ getNodeFromPreferenceId(id: string): Preference.TreeNode | undefined {
245
+ const node = this.getNode(this.treeGenerator.getNodeId(id));
246
+ return node && Preference.TreeNode.is(node) ? node : undefined;
247
+ }
248
+
249
+ /**
250
+ * @returns true if selection changed, false otherwise
251
+ */
252
+ selectIfNotSelected(node: SelectableTreeNode): boolean {
253
+ const currentlySelected = this.selectedNodes[0];
254
+ if (node !== currentlySelected) {
255
+ this.selectNode(node);
256
+ return true;
257
+ }
258
+ return false;
259
+ }
260
+ }