@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,377 +1,381 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2024 TypeFox 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 { nls } from '@theia/core';
18
- import { injectable } from '@theia/core/shared/inversify';
19
-
20
- export interface PreferenceLayout {
21
- id: string;
22
- label: string;
23
- children?: PreferenceLayout[];
24
- settings?: string[];
25
- }
26
-
27
- export const COMMONLY_USED_SECTION_PREFIX = 'commonly-used';
28
-
29
- export const COMMONLY_USED_LAYOUT = {
30
- id: COMMONLY_USED_SECTION_PREFIX,
31
- label: nls.localizeByDefault('Commonly Used'),
32
- settings: [
33
- 'files.autoSave',
34
- 'editor.fontSize',
35
- 'editor.fontFamily',
36
- 'editor.tabSize',
37
- 'editor.renderWhitespace',
38
- 'editor.cursorStyle',
39
- 'editor.multiCursorModifier',
40
- 'editor.insertSpaces',
41
- 'editor.wordWrap',
42
- 'files.exclude',
43
- 'files.associations'
44
- ]
45
- };
46
-
47
- export const DEFAULT_LAYOUT: PreferenceLayout[] = [
48
- {
49
- id: 'editor',
50
- label: nls.localizeByDefault('Text Editor'),
51
- settings: ['editor.*'],
52
- children: [
53
- {
54
- id: 'editor.cursor',
55
- label: nls.localizeByDefault('Cursor'),
56
- settings: ['editor.cursor*']
57
- },
58
- {
59
- id: 'editor.find',
60
- label: nls.localizeByDefault('Find'),
61
- settings: ['editor.find.*']
62
- },
63
- {
64
- id: 'editor.font',
65
- label: nls.localizeByDefault('Font'),
66
- settings: ['editor.font*']
67
- },
68
- {
69
- id: 'editor.format',
70
- label: nls.localizeByDefault('Formatting'),
71
- settings: ['editor.format*']
72
- },
73
- {
74
- id: 'editor.diffEditor',
75
- label: nls.localizeByDefault('Diff Editor'),
76
- settings: ['diffEditor.*']
77
- },
78
- {
79
- id: 'editor.multiDiffEditor',
80
- label: nls.localizeByDefault('Multi-File Diff Editor'),
81
- settings: ['multiDiffEditor.*']
82
- },
83
- {
84
- id: 'editor.minimap',
85
- label: nls.localizeByDefault('Minimap'),
86
- settings: ['editor.minimap.*']
87
- },
88
- {
89
- id: 'editor.suggestions',
90
- label: nls.localizeByDefault('Suggestions'),
91
- settings: ['editor.*suggest*']
92
- },
93
- {
94
- id: 'editor.files',
95
- label: nls.localizeByDefault('Files'),
96
- settings: ['files.*']
97
- }
98
- ]
99
- },
100
- {
101
- id: 'workbench',
102
- label: nls.localizeByDefault('Workbench'),
103
- settings: ['workbench.*', 'workspace.*'],
104
- children: [
105
- {
106
- id: 'workbench.appearance',
107
- label: nls.localizeByDefault('Appearance'),
108
- settings: [
109
- 'workbench.activityBar.*', 'workbench.*color*', 'workbench.fontAliasing', 'workbench.iconTheme', 'workbench.sidebar.location',
110
- 'workbench.*.visible', 'workbench.tips.enabled', 'workbench.tree.*', 'workbench.view.*'
111
- ]
112
- },
113
- {
114
- id: 'workbench.breadcrumbs',
115
- label: nls.localizeByDefault('Breadcrumbs'),
116
- settings: ['breadcrumbs.*']
117
- },
118
- {
119
- id: 'workbench.editor',
120
- label: nls.localizeByDefault('Editor Management'),
121
- settings: ['workbench.editor.*']
122
- },
123
- {
124
- id: 'workbench.settings',
125
- label: nls.localizeByDefault('Settings Editor'),
126
- settings: ['workbench.settings.*']
127
- },
128
- {
129
- id: 'workbench.zenmode',
130
- label: nls.localizeByDefault('Zen Mode'),
131
- settings: ['zenmode.*']
132
- },
133
- {
134
- id: 'workbench.screencastmode',
135
- label: nls.localizeByDefault('Screencast Mode'),
136
- settings: ['screencastMode.*']
137
- }
138
- ]
139
- },
140
- {
141
- id: 'window',
142
- label: nls.localizeByDefault('Window'),
143
- settings: ['window.*'],
144
- children: [
145
- {
146
- id: 'window.newWindow',
147
- label: nls.localizeByDefault('New Window'),
148
- settings: ['window.*newwindow*']
149
- }
150
- ]
151
- },
152
- {
153
- id: 'features',
154
- label: nls.localizeByDefault('Features'),
155
- children: [
156
- {
157
- id: 'features.accessibilitySignals',
158
- label: nls.localizeByDefault('Accessibility Signals'),
159
- settings: ['accessibility.signal*']
160
- },
161
- {
162
- id: 'features.accessibility',
163
- label: nls.localizeByDefault('Accessibility'),
164
- settings: ['accessibility.*']
165
- },
166
- {
167
- id: 'features.explorer',
168
- label: nls.localizeByDefault('Explorer'),
169
- settings: ['explorer.*', 'outline.*']
170
- },
171
- {
172
- id: 'features.search',
173
- label: nls.localizeByDefault('Search'),
174
- settings: ['search.*']
175
- },
176
- {
177
- id: 'features.debug',
178
- label: nls.localizeByDefault('Debug'),
179
- settings: ['debug.*', 'launch']
180
- },
181
- {
182
- id: 'features.testing',
183
- label: nls.localizeByDefault('Testing'),
184
- settings: ['testing.*']
185
- },
186
- {
187
- id: 'features.scm',
188
- label: nls.localizeByDefault('Source Control'),
189
- settings: ['scm.*']
190
- },
191
- {
192
- id: 'features.extensions',
193
- label: nls.localizeByDefault('Extensions'),
194
- settings: ['extensions.*']
195
- },
196
- {
197
- id: 'features.terminal',
198
- label: nls.localizeByDefault('Terminal'),
199
- settings: ['terminal.*']
200
- },
201
- {
202
- id: 'features.task',
203
- label: nls.localizeByDefault('Task'),
204
- settings: ['task.*']
205
- },
206
- {
207
- id: 'features.problems',
208
- label: nls.localizeByDefault('Problems'),
209
- settings: ['problems.*']
210
- },
211
- {
212
- id: 'features.output',
213
- label: nls.localizeByDefault('Output'),
214
- settings: ['output.*']
215
- },
216
- {
217
- id: 'features.comments',
218
- label: nls.localizeByDefault('Comments'),
219
- settings: ['comments.*']
220
- },
221
- {
222
- id: 'features.remote',
223
- label: nls.localizeByDefault('Remote'),
224
- settings: ['remote.*']
225
- },
226
- {
227
- id: 'features.timeline',
228
- label: nls.localizeByDefault('Timeline'),
229
- settings: ['timeline.*']
230
- },
231
- {
232
- id: 'features.toolbar',
233
- label: nls.localize('theia/preferences/toolbar', 'Toolbar'),
234
- settings: ['toolbar.*']
235
- },
236
- {
237
- id: 'features.notebook',
238
- label: nls.localizeByDefault('Notebook'),
239
- settings: ['notebook.*', 'interactiveWindow.*']
240
- },
241
- {
242
- id: 'features.mergeEditor',
243
- label: nls.localizeByDefault('Merge Editor'),
244
- settings: ['mergeEditor.*']
245
- },
246
- {
247
- id: 'features.chat',
248
- label: nls.localizeByDefault('Chat'),
249
- settings: ['chat.*', 'inlineChat.*']
250
- }
251
- ]
252
- },
253
- {
254
- id: 'application',
255
- label: nls.localizeByDefault('Application'),
256
- children: [
257
- {
258
- id: 'application.http',
259
- label: nls.localizeByDefault('HTTP'),
260
- settings: ['http.*']
261
- },
262
- {
263
- id: 'application.keyboard',
264
- label: nls.localizeByDefault('Keyboard'),
265
- settings: ['keyboard.*']
266
- },
267
- {
268
- id: 'application.update',
269
- label: nls.localizeByDefault('Update'),
270
- settings: ['update.*']
271
- },
272
- {
273
- id: 'application.telemetry',
274
- label: nls.localizeByDefault('Telemetry'),
275
- settings: ['telemetry.*']
276
- },
277
- {
278
- id: 'application.settingsSync',
279
- label: nls.localizeByDefault('Settings Sync'),
280
- settings: ['settingsSync.*']
281
- },
282
- {
283
- id: 'application.experimental',
284
- label: nls.localizeByDefault('Experimental'),
285
- settings: ['application.experimental.*']
286
- },
287
- {
288
- id: 'application.other',
289
- label: nls.localizeByDefault('Other'),
290
- settings: ['application.*']
291
- }
292
- ]
293
- },
294
- {
295
- id: 'security',
296
- label: nls.localizeByDefault('Security'),
297
- settings: ['security.*'],
298
- children: [
299
- {
300
- id: 'security.workspace',
301
- label: nls.localizeByDefault('Workspace'),
302
- settings: ['security.workspace.*']
303
- }
304
- ]
305
- },
306
- {
307
- id: 'extensions',
308
- label: nls.localizeByDefault('Extensions'),
309
- children: [
310
- {
311
- id: 'extensions.hosted-plugin',
312
- label: nls.localize('theia/preferences/hostedPlugin', 'Hosted Plugin'),
313
- settings: ['hosted-plugin.*']
314
- }
315
- ]
316
- }
317
- ];
318
-
319
- @injectable()
320
- export class PreferenceLayoutProvider {
321
-
322
- getLayout(): PreferenceLayout[] {
323
- return DEFAULT_LAYOUT;
324
- }
325
-
326
- getCommonlyUsedLayout(): PreferenceLayout {
327
- return COMMONLY_USED_LAYOUT;
328
- }
329
-
330
- hasCategory(id: string): boolean {
331
- return [...this.getLayout(), this.getCommonlyUsedLayout()].some(e => e.id === id);
332
- }
333
-
334
- getLayoutForPreference(preferenceId: string): PreferenceLayout | undefined {
335
- const layout = this.getLayout();
336
- for (const section of layout) {
337
- const item = this.findItemInSection(section, preferenceId);
338
- if (item) {
339
- return item;
340
- }
341
- }
342
- return undefined;
343
- }
344
-
345
- protected findItemInSection(section: PreferenceLayout, preferenceId: string): PreferenceLayout | undefined {
346
- // First check whether any of its children match the preferenceId.
347
- if (section.children) {
348
- for (const child of section.children) {
349
- const item = this.findItemInSection(child, preferenceId);
350
- if (item) {
351
- return item;
352
- }
353
- }
354
- }
355
- // Then check whether the section itself matches the preferenceId.
356
- if (section.settings) {
357
- for (const setting of section.settings) {
358
- if (this.matchesSetting(preferenceId, setting)) {
359
- return section;
360
- }
361
- }
362
- }
363
- return undefined;
364
- }
365
-
366
- protected matchesSetting(preferenceId: string, setting: string): boolean {
367
- if (setting.includes('*')) {
368
- return this.createRegExp(setting).test(preferenceId);
369
- }
370
- return preferenceId === setting;
371
- }
372
-
373
- protected createRegExp(setting: string): RegExp {
374
- return new RegExp(`^${setting.replace(/\./g, '\\.').replace(/\*/g, '.*')}$`);
375
- }
376
-
377
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 TypeFox 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 { nls } from '@theia/core';
18
+ import { injectable } from '@theia/core/shared/inversify';
19
+
20
+ export interface PreferenceLayout {
21
+ id: string;
22
+ label: string;
23
+ children?: PreferenceLayout[];
24
+ settings?: string[];
25
+ }
26
+
27
+ export const COMMONLY_USED_SECTION_PREFIX = 'commonly-used';
28
+
29
+ export const COMMONLY_USED_LAYOUT = {
30
+ id: COMMONLY_USED_SECTION_PREFIX,
31
+ label: nls.localizeByDefault('Commonly Used'),
32
+ settings: [
33
+ 'files.autoSave',
34
+ 'editor.fontSize',
35
+ 'editor.fontFamily',
36
+ 'editor.tabSize',
37
+ 'editor.renderWhitespace',
38
+ 'editor.cursorStyle',
39
+ 'editor.multiCursorModifier',
40
+ 'editor.insertSpaces',
41
+ 'editor.wordWrap',
42
+ 'files.exclude',
43
+ 'files.associations'
44
+ ]
45
+ };
46
+
47
+ export const DEFAULT_LAYOUT: PreferenceLayout[] = [
48
+ {
49
+ id: 'editor',
50
+ label: nls.localizeByDefault('Text Editor'),
51
+ settings: ['editor.*'],
52
+ children: [
53
+ {
54
+ id: 'editor.cursor',
55
+ label: nls.localizeByDefault('Cursor'),
56
+ settings: ['editor.cursor*']
57
+ },
58
+ {
59
+ id: 'editor.find',
60
+ label: nls.localizeByDefault('Find'),
61
+ settings: ['editor.find.*']
62
+ },
63
+ {
64
+ id: 'editor.font',
65
+ label: nls.localizeByDefault('Font'),
66
+ settings: ['editor.font*']
67
+ },
68
+ {
69
+ id: 'editor.format',
70
+ label: nls.localizeByDefault('Formatting'),
71
+ settings: ['editor.format*']
72
+ },
73
+ {
74
+ id: 'editor.diffEditor',
75
+ label: nls.localizeByDefault('Diff Editor'),
76
+ settings: ['diffEditor.*']
77
+ },
78
+ {
79
+ id: 'editor.multiDiffEditor',
80
+ label: nls.localizeByDefault('Multi-File Diff Editor'),
81
+ settings: ['multiDiffEditor.*']
82
+ },
83
+ {
84
+ id: 'editor.minimap',
85
+ label: nls.localizeByDefault('Minimap'),
86
+ settings: ['editor.minimap.*']
87
+ },
88
+ {
89
+ id: 'editor.suggestions',
90
+ label: nls.localizeByDefault('Suggestions'),
91
+ settings: ['editor.*suggest*']
92
+ },
93
+ {
94
+ id: 'editor.files',
95
+ label: nls.localizeByDefault('Files'),
96
+ settings: ['files.*']
97
+ }
98
+ ]
99
+ },
100
+ {
101
+ id: 'workbench',
102
+ label: nls.localizeByDefault('Workbench'),
103
+ settings: ['workbench.*', 'workspace.*'],
104
+ children: [
105
+ {
106
+ id: 'workbench.appearance',
107
+ label: nls.localizeByDefault('Appearance'),
108
+ settings: [
109
+ 'workbench.activityBar.*', 'workbench.*color*', 'workbench.fontAliasing', 'workbench.iconTheme', 'workbench.sidebar.location',
110
+ 'workbench.*.visible', 'workbench.tips.enabled', 'workbench.tree.*', 'workbench.view.*'
111
+ ]
112
+ },
113
+ {
114
+ id: 'workbench.breadcrumbs',
115
+ label: nls.localizeByDefault('Breadcrumbs'),
116
+ settings: ['breadcrumbs.*']
117
+ },
118
+ {
119
+ id: 'workbench.editor',
120
+ label: nls.localizeByDefault('Editor Management'),
121
+ settings: ['workbench.editor.*']
122
+ },
123
+ {
124
+ id: 'workbench.settings',
125
+ label: nls.localizeByDefault('Settings Editor'),
126
+ settings: ['workbench.settings.*']
127
+ },
128
+ {
129
+ id: 'workbench.zenmode',
130
+ label: nls.localizeByDefault('Zen Mode'),
131
+ settings: ['zenmode.*']
132
+ },
133
+ {
134
+ id: 'workbench.screencastmode',
135
+ label: nls.localizeByDefault('Screencast Mode'),
136
+ settings: ['screencastMode.*']
137
+ }
138
+ ]
139
+ },
140
+ {
141
+ id: 'window',
142
+ label: nls.localizeByDefault('Window'),
143
+ settings: ['window.*'],
144
+ children: [
145
+ {
146
+ id: 'window.newWindow',
147
+ label: nls.localizeByDefault('New Window'),
148
+ settings: ['window.*newwindow*']
149
+ }
150
+ ]
151
+ },
152
+ {
153
+ id: 'features',
154
+ label: nls.localizeByDefault('Features'),
155
+ children: [
156
+ {
157
+ id: 'features.accessibilitySignals',
158
+ label: nls.localizeByDefault('Accessibility Signals'),
159
+ settings: ['accessibility.signal*']
160
+ },
161
+ {
162
+ id: 'features.accessibility',
163
+ label: nls.localizeByDefault('Accessibility'),
164
+ settings: ['accessibility.*']
165
+ },
166
+ {
167
+ id: 'features.explorer',
168
+ label: nls.localizeByDefault('Explorer'),
169
+ settings: ['explorer.*', 'outline.*']
170
+ },
171
+ {
172
+ id: 'features.search',
173
+ label: nls.localizeByDefault('Search'),
174
+ settings: ['search.*']
175
+ },
176
+ {
177
+ id: 'features.debug',
178
+ label: nls.localizeByDefault('Debug'),
179
+ settings: ['debug.*', 'launch']
180
+ },
181
+ {
182
+ id: 'features.testing',
183
+ label: nls.localizeByDefault('Testing'),
184
+ settings: ['testing.*']
185
+ },
186
+ {
187
+ id: 'features.scm',
188
+ label: nls.localizeByDefault('Source Control'),
189
+ settings: ['scm.*']
190
+ },
191
+ {
192
+ id: 'features.extensions',
193
+ label: nls.localizeByDefault('Extensions'),
194
+ settings: ['extensions.*']
195
+ },
196
+ {
197
+ id: 'features.terminal',
198
+ label: nls.localizeByDefault('Terminal'),
199
+ settings: ['terminal.*']
200
+ },
201
+ {
202
+ id: 'features.task',
203
+ label: nls.localizeByDefault('Task'),
204
+ settings: ['task.*']
205
+ },
206
+ {
207
+ id: 'features.problems',
208
+ label: nls.localizeByDefault('Problems'),
209
+ settings: ['problems.*']
210
+ },
211
+ {
212
+ id: 'features.output',
213
+ label: nls.localizeByDefault('Output'),
214
+ settings: ['output.*']
215
+ },
216
+ {
217
+ id: 'features.comments',
218
+ label: nls.localizeByDefault('Comments'),
219
+ settings: ['comments.*']
220
+ },
221
+ {
222
+ id: 'features.remote',
223
+ label: nls.localizeByDefault('Remote'),
224
+ settings: ['remote.*']
225
+ },
226
+ {
227
+ id: 'features.timeline',
228
+ label: nls.localizeByDefault('Timeline'),
229
+ settings: ['timeline.*']
230
+ },
231
+ {
232
+ id: 'features.toolbar',
233
+ label: nls.localize('theia/preferences/toolbar', 'Toolbar'),
234
+ settings: ['toolbar.*']
235
+ },
236
+ {
237
+ id: 'features.notebook',
238
+ label: nls.localizeByDefault('Notebook'),
239
+ settings: ['notebook.*', 'interactiveWindow.*']
240
+ },
241
+ {
242
+ id: 'features.mergeEditor',
243
+ label: nls.localizeByDefault('Merge Editor'),
244
+ settings: ['mergeEditor.*']
245
+ },
246
+ {
247
+ id: 'features.chat',
248
+ label: nls.localizeByDefault('Chat'),
249
+ settings: ['chat.*', 'inlineChat.*']
250
+ }
251
+ ]
252
+ },
253
+ {
254
+ id: 'application',
255
+ label: nls.localizeByDefault('Application'),
256
+ children: [
257
+ {
258
+ id: 'application.http',
259
+ label: nls.localizeByDefault('HTTP'),
260
+ settings: ['http.*']
261
+ },
262
+ {
263
+ id: 'application.keyboard',
264
+ label: nls.localizeByDefault('Keyboard'),
265
+ settings: ['keyboard.*']
266
+ },
267
+ {
268
+ id: 'application.update',
269
+ label: nls.localizeByDefault('Update'),
270
+ settings: ['update.*']
271
+ },
272
+ {
273
+ id: 'application.telemetry',
274
+ label: nls.localizeByDefault('Telemetry'),
275
+ settings: ['telemetry.*']
276
+ },
277
+ {
278
+ id: 'application.settingsSync',
279
+ label: nls.localizeByDefault('Settings Sync'),
280
+ settings: ['settingsSync.*']
281
+ },
282
+ {
283
+ id: 'application.experimental',
284
+ label: nls.localizeByDefault('Experimental'),
285
+ settings: ['application.experimental.*']
286
+ },
287
+ {
288
+ id: 'application.other',
289
+ label: nls.localizeByDefault('Other'),
290
+ settings: ['application.*']
291
+ }
292
+ ]
293
+ },
294
+ {
295
+ id: 'security',
296
+ label: nls.localizeByDefault('Security'),
297
+ settings: ['security.*'],
298
+ children: [
299
+ {
300
+ id: 'security.workspace',
301
+ label: nls.localizeByDefault('Workspace'),
302
+ settings: ['security.workspace.*']
303
+ }
304
+ ]
305
+ },
306
+ {
307
+ id: 'ai-features',
308
+ label: 'AI Features', // TODO localize
309
+ },
310
+ {
311
+ id: 'extensions',
312
+ label: nls.localizeByDefault('Extensions'),
313
+ children: [
314
+ {
315
+ id: 'extensions.hosted-plugin',
316
+ label: nls.localize('theia/preferences/hostedPlugin', 'Hosted Plugin'),
317
+ settings: ['hosted-plugin.*']
318
+ }
319
+ ]
320
+ }
321
+ ];
322
+
323
+ @injectable()
324
+ export class PreferenceLayoutProvider {
325
+
326
+ getLayout(): PreferenceLayout[] {
327
+ return DEFAULT_LAYOUT;
328
+ }
329
+
330
+ getCommonlyUsedLayout(): PreferenceLayout {
331
+ return COMMONLY_USED_LAYOUT;
332
+ }
333
+
334
+ hasCategory(id: string): boolean {
335
+ return [...this.getLayout(), this.getCommonlyUsedLayout()].some(e => e.id === id);
336
+ }
337
+
338
+ getLayoutForPreference(preferenceId: string): PreferenceLayout | undefined {
339
+ const layout = this.getLayout();
340
+ for (const section of layout) {
341
+ const item = this.findItemInSection(section, preferenceId);
342
+ if (item) {
343
+ return item;
344
+ }
345
+ }
346
+ return undefined;
347
+ }
348
+
349
+ protected findItemInSection(section: PreferenceLayout, preferenceId: string): PreferenceLayout | undefined {
350
+ // First check whether any of its children match the preferenceId.
351
+ if (section.children) {
352
+ for (const child of section.children) {
353
+ const item = this.findItemInSection(child, preferenceId);
354
+ if (item) {
355
+ return item;
356
+ }
357
+ }
358
+ }
359
+ // Then check whether the section itself matches the preferenceId.
360
+ if (section.settings) {
361
+ for (const setting of section.settings) {
362
+ if (this.matchesSetting(preferenceId, setting)) {
363
+ return section;
364
+ }
365
+ }
366
+ }
367
+ return undefined;
368
+ }
369
+
370
+ protected matchesSetting(preferenceId: string, setting: string): boolean {
371
+ if (setting.includes('*')) {
372
+ return this.createRegExp(setting).test(preferenceId);
373
+ }
374
+ return preferenceId === setting;
375
+ }
376
+
377
+ protected createRegExp(setting: string): RegExp {
378
+ return new RegExp(`^${setting.replace(/\./g, '\\.').replace(/\*/g, '.*')}$`);
379
+ }
380
+
381
+ }