@opensumi/ide-preferences 2.21.13 → 2.22.0

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 (80) hide show
  1. package/lib/browser/abstract-resource-preference-provider.d.ts +1 -0
  2. package/lib/browser/abstract-resource-preference-provider.d.ts.map +1 -1
  3. package/lib/browser/abstract-resource-preference-provider.js +22 -3
  4. package/lib/browser/abstract-resource-preference-provider.js.map +1 -1
  5. package/lib/browser/folder-file-preference-provider.d.ts +24 -0
  6. package/lib/browser/folder-file-preference-provider.d.ts.map +1 -0
  7. package/lib/browser/{folder-preference-provider.js → folder-file-preference-provider.js} +12 -14
  8. package/lib/browser/folder-file-preference-provider.js.map +1 -0
  9. package/lib/browser/folders-preferences-provider.d.ts +8 -8
  10. package/lib/browser/folders-preferences-provider.d.ts.map +1 -1
  11. package/lib/browser/folders-preferences-provider.js +7 -7
  12. package/lib/browser/folders-preferences-provider.js.map +1 -1
  13. package/lib/browser/index.d.ts.map +1 -1
  14. package/lib/browser/index.js +8 -8
  15. package/lib/browser/index.js.map +1 -1
  16. package/lib/browser/preference-contribution.d.ts.map +1 -1
  17. package/lib/browser/preference-contribution.js +3 -3
  18. package/lib/browser/preference-contribution.js.map +1 -1
  19. package/lib/browser/preference-settings.service.d.ts +22 -10
  20. package/lib/browser/preference-settings.service.d.ts.map +1 -1
  21. package/lib/browser/preference-settings.service.js +284 -101
  22. package/lib/browser/preference-settings.service.js.map +1 -1
  23. package/lib/browser/preference-widgets.js.map +1 -1
  24. package/lib/browser/preferenceItem.view.d.ts +4 -3
  25. package/lib/browser/preferenceItem.view.d.ts.map +1 -1
  26. package/lib/browser/preferenceItem.view.js +125 -62
  27. package/lib/browser/preferenceItem.view.js.map +1 -1
  28. package/lib/browser/preferences.module.less +100 -60
  29. package/lib/browser/preferences.view.d.ts +3 -17
  30. package/lib/browser/preferences.view.d.ts.map +1 -1
  31. package/lib/browser/preferences.view.js +194 -112
  32. package/lib/browser/preferences.view.js.map +1 -1
  33. package/lib/browser/user-preference-provider.js.map +1 -1
  34. package/lib/browser/userstorage/user-storage.contribution.js.map +1 -1
  35. package/lib/browser/userstorage/user-storage.service.js +7 -7
  36. package/lib/browser/userstorage/user-storage.service.js.map +1 -1
  37. package/lib/browser/workspace-file-preference-provider.d.ts +1 -1
  38. package/lib/browser/workspace-file-preference-provider.d.ts.map +1 -1
  39. package/lib/browser/workspace-file-preference-provider.js.map +1 -1
  40. package/lib/browser/workspace-preference-provider.js.map +1 -1
  41. package/lib/common/preference-id.d.ts +3 -0
  42. package/lib/common/preference-id.d.ts.map +1 -1
  43. package/lib/common/preference-id.js +4 -1
  44. package/lib/common/preference-id.js.map +1 -1
  45. package/lib/common/preference.d.ts +1 -0
  46. package/lib/common/preference.d.ts.map +1 -1
  47. package/lib/common/preference.js +26 -4
  48. package/lib/common/preference.js.map +1 -1
  49. package/lib/common/types.d.ts +18 -3
  50. package/lib/common/types.d.ts.map +1 -1
  51. package/lib/common/user-storage.d.ts +1 -1
  52. package/lib/common/user-storage.d.ts.map +1 -1
  53. package/package.json +12 -11
  54. package/src/browser/abstract-resource-preference-provider.ts +357 -0
  55. package/src/browser/folder-file-preference-provider.ts +56 -0
  56. package/src/browser/folders-preferences-provider.ts +262 -0
  57. package/src/browser/index.ts +125 -0
  58. package/src/browser/preference-contribution.ts +432 -0
  59. package/src/browser/preference-settings.service.ts +810 -0
  60. package/src/browser/preference-widgets.ts +368 -0
  61. package/src/browser/preferenceItem.view.tsx +787 -0
  62. package/src/browser/preferences.module.less +345 -0
  63. package/src/browser/preferences.view.tsx +388 -0
  64. package/src/browser/user-preference-provider.ts +18 -0
  65. package/src/browser/userstorage/index.ts +2 -0
  66. package/src/browser/userstorage/user-storage.contribution.ts +19 -0
  67. package/src/browser/userstorage/user-storage.service.ts +192 -0
  68. package/src/browser/workspace-file-preference-provider.ts +50 -0
  69. package/src/browser/workspace-preference-provider.ts +129 -0
  70. package/src/common/commands.ts +5 -0
  71. package/src/common/index.ts +4 -0
  72. package/src/common/preference-id.ts +11 -0
  73. package/src/common/preference.ts +51 -0
  74. package/src/common/types.ts +63 -0
  75. package/src/common/user-storage.ts +6 -0
  76. package/src/index.ts +1 -0
  77. package/lib/browser/folder-preference-provider.d.ts +0 -26
  78. package/lib/browser/folder-preference-provider.d.ts.map +0 -1
  79. package/lib/browser/folder-preference-provider.js.map +0 -1
  80. package/lib/browser/index.less +0 -36
@@ -0,0 +1,810 @@
1
+ import debounce from 'lodash/debounce';
2
+ import { observable, action, computed, autorun, trace } from 'mobx';
3
+
4
+ import { Injectable, Autowired } from '@opensumi/di';
5
+ import { IBasicRecycleTreeHandle, IRecycleTreeHandle } from '@opensumi/ide-components';
6
+ import { IVirtualListHandle } from '@opensumi/ide-components/lib/virtual-list/types';
7
+ import {
8
+ IPreferenceViewDesc,
9
+ IPreferenceSettingsService,
10
+ ISettingGroup,
11
+ ISettingSection,
12
+ PreferenceProviderProvider,
13
+ Emitter,
14
+ Event,
15
+ CommandService,
16
+ getDebugLogger,
17
+ isString,
18
+ getIcon,
19
+ PreferenceScope,
20
+ PreferenceProvider,
21
+ PreferenceSchemaProvider,
22
+ IDisposable,
23
+ arrays,
24
+ getAvailableLanguages,
25
+ PreferenceService,
26
+ replaceLocalizePlaceholder,
27
+ ThrottledDelayer,
28
+ TerminalSettingsId,
29
+ IResolvedPreferenceViewDesc,
30
+ IResolvedSettingSection,
31
+ Disposable,
32
+ UserScope,
33
+ WorkspaceScope,
34
+ } from '@opensumi/ide-core-browser';
35
+ import { SearchSettingId } from '@opensumi/ide-core-common/lib/settings/search';
36
+ import { IFileServiceClient } from '@opensumi/ide-file-service';
37
+
38
+ import { toPreferenceReadableName, PreferenceSettingId, getPreferenceItemLabel, ESectionItemKind } from '../common';
39
+
40
+ import { PREFERENCE_COMMANDS } from './preference-contribution';
41
+
42
+ const { addElement } = arrays;
43
+
44
+ @Injectable()
45
+ export class PreferenceSettingsService extends Disposable implements IPreferenceSettingsService {
46
+ private static DEFAULT_CHANGE_DELAY = 500;
47
+
48
+ @Autowired(PreferenceService)
49
+ protected readonly preferenceService: PreferenceService;
50
+
51
+ @Autowired(PreferenceSchemaProvider)
52
+ protected readonly schemaProvider: PreferenceSchemaProvider;
53
+
54
+ @Autowired(PreferenceProviderProvider)
55
+ protected readonly providerProvider: PreferenceProviderProvider;
56
+
57
+ @Autowired(IFileServiceClient)
58
+ protected readonly fileServiceClient: IFileServiceClient;
59
+
60
+ @Autowired(CommandService)
61
+ protected readonly commandService: CommandService;
62
+
63
+ @observable
64
+ public currentSearch = '';
65
+
66
+ @observable
67
+ currentSelectId = '';
68
+
69
+ @observable
70
+ private userBeforeWorkspace = false;
71
+
72
+ @observable
73
+ tabIndex = 0;
74
+
75
+ @computed
76
+ get tabList() {
77
+ return this.userBeforeWorkspace ? [UserScope, WorkspaceScope] : [WorkspaceScope, UserScope];
78
+ }
79
+
80
+ @computed
81
+ get groups() {
82
+ return this.getSettingGroups(this.currentScope, this.currentSearch);
83
+ }
84
+
85
+ @computed
86
+ get currentScope() {
87
+ const scope = this.tabList[this.tabIndex];
88
+ return scope.id;
89
+ }
90
+
91
+ @observable
92
+ private settingsGroups: ISettingGroup[] = [];
93
+
94
+ private settingsSections: Map<string, ISettingSection[]> = new Map();
95
+
96
+ private enumLabels: Map<string, { [key: string]: string }> = new Map();
97
+
98
+ private cachedGroupSection: Map<string, IResolvedSettingSection[]> = new Map();
99
+
100
+ private _listHandler: IVirtualListHandle;
101
+ private _treeHandler: IBasicRecycleTreeHandle;
102
+ private onDidEnumLabelsChangeEmitter: Emitter<void> = this.registerDispose(new Emitter());
103
+ private enumLabelsChangeDelayer = this.registerDispose(
104
+ new ThrottledDelayer<void>(PreferenceSettingsService.DEFAULT_CHANGE_DELAY),
105
+ );
106
+
107
+ private onDidSettingsChangeEmitter: Emitter<void> = this.registerDispose(new Emitter());
108
+
109
+ constructor() {
110
+ super();
111
+ this.setEnumLabels(
112
+ 'general.language',
113
+ new Proxy(
114
+ {},
115
+ {
116
+ get: (target, key) => getAvailableLanguages().find((l) => l.languageId === key)?.localizedLanguageName,
117
+ },
118
+ ),
119
+ );
120
+ this.setEnumLabels('files.eol', {
121
+ '\n': 'LF',
122
+ '\r\n': 'CRLF',
123
+ auto: 'auto',
124
+ });
125
+ this.userBeforeWorkspace = this.preferenceService.get<boolean>('settings.userBeforeWorkspace', false);
126
+
127
+ this.registerDispose(
128
+ this.preferenceService.onSpecificPreferenceChange('settings.userBeforeWorkspace', (e) => {
129
+ this.userBeforeWorkspace = e.newValue;
130
+ }),
131
+ );
132
+ this.registerDispose(
133
+ this.onDidSettingsChange(
134
+ debounce(
135
+ action(() => {
136
+ // 利用副作用强制刷新一下
137
+ this.selectScope(this.currentScope);
138
+ }),
139
+ 100,
140
+ {
141
+ maxWait: 300,
142
+ },
143
+ ),
144
+ ),
145
+ );
146
+ }
147
+
148
+ @action
149
+ scrollToGroup(groupId: string): void {
150
+ if (groupId) {
151
+ this.currentSelectId = ESectionItemKind.Group + groupId;
152
+ }
153
+ }
154
+ @action
155
+ scrollToSection(section: string): void {
156
+ if (section) {
157
+ this.currentSelectId = ESectionItemKind.Section + section;
158
+ }
159
+ }
160
+ @action
161
+ scrollToPreference(preferenceId: string): void {
162
+ if (preferenceId) {
163
+ this.currentSelectId = ESectionItemKind.Preference + preferenceId;
164
+ }
165
+ }
166
+
167
+ @action.bound
168
+ selectScope(scope: PreferenceScope) {
169
+ // 利用副作用强制刷新一下
170
+ let index = this.tabList.findIndex((v) => v.id === scope);
171
+ if (index === -1) {
172
+ index = 0;
173
+ }
174
+ this.tabIndex = index;
175
+ }
176
+
177
+ get onDidEnumLabelsChange() {
178
+ return this.onDidEnumLabelsChangeEmitter.event;
179
+ }
180
+
181
+ get onDidSettingsChange() {
182
+ return this.onDidSettingsChangeEmitter.event;
183
+ }
184
+
185
+ fireDidSettingsChange() {
186
+ this.onDidSettingsChangeEmitter.fire();
187
+ }
188
+
189
+ private isContainSearchValue(value: string, search: string) {
190
+ return value.toLocaleLowerCase().indexOf(search.toLocaleLowerCase()) > -1;
191
+ }
192
+
193
+ private filterPreferences(preference: IPreferenceViewDesc, scope: PreferenceScope): boolean {
194
+ return Array.isArray(preference.hiddenInScope) && preference.hiddenInScope.includes(scope);
195
+ }
196
+
197
+ @action
198
+ private doSearch(value) {
199
+ if (value) {
200
+ this.currentSearch = value;
201
+ } else {
202
+ this.currentSearch = '';
203
+ }
204
+ }
205
+
206
+ openJSON = (scope: PreferenceScope, preferenceId: string) => {
207
+ // 根据节点信息打开 Settings.json 配置文件
208
+ this.commandService.executeCommand(PREFERENCE_COMMANDS.OPEN_SOURCE_FILE.id, scope, preferenceId);
209
+ };
210
+
211
+ /**
212
+ * 设置某个作用域下的配置值
213
+ * @param key 配置Key
214
+ * @param value 配置值
215
+ * @param scope 作用域
216
+ */
217
+ async setPreference(key: string, value: any, scope: PreferenceScope) {
218
+ await this.preferenceService.set(key, value, scope);
219
+ }
220
+
221
+ get listHandler() {
222
+ return this._listHandler;
223
+ }
224
+
225
+ handleListHandler = (handler: IVirtualListHandle) => {
226
+ this._listHandler = handler;
227
+ };
228
+
229
+ get treeHandler() {
230
+ return this._treeHandler;
231
+ }
232
+ handleTreeHandler = (handler: IBasicRecycleTreeHandle) => {
233
+ this._treeHandler = handler;
234
+ };
235
+
236
+ /**
237
+ * 获取搜索条件下展示的设置面板配置组
238
+ * @param scope 作用域
239
+ * @param search 搜索值
240
+ */
241
+ getSettingGroups(scope: PreferenceScope, search?: string | undefined): ISettingGroup[] {
242
+ const groups = this.settingsGroups.slice();
243
+ return groups.filter((g) => this.getResolvedSections(g.id, scope, search).length > 0);
244
+ }
245
+
246
+ async hasThisScopeSetting(scope: PreferenceScope) {
247
+ const url = await this.getPreferenceUrl(scope);
248
+ if (!url) {
249
+ return;
250
+ }
251
+
252
+ const exist = await this.fileServiceClient.access(url);
253
+ return exist;
254
+ }
255
+
256
+ /**
257
+ * 注册配置组
258
+ * @param group 配置组
259
+ */
260
+ registerSettingGroup(group: ISettingGroup): IDisposable {
261
+ const disposable = addElement(this.settingsGroups, {
262
+ ...group,
263
+ title: replaceLocalizePlaceholder(group.title) || group.title,
264
+ });
265
+ this.fireDidSettingsChange();
266
+ return disposable;
267
+ }
268
+
269
+ /**
270
+ * 在某个配置组下注册配置项
271
+ * @param groupId 配置组ID
272
+ * @param section 配置项内容
273
+ */
274
+ registerSettingSection(groupId: string, section: ISettingSection): IDisposable {
275
+ if (!this.settingsSections.has(groupId)) {
276
+ this.settingsSections.set(groupId, []);
277
+ }
278
+ this.cachedGroupSection.clear();
279
+ const disposable = addElement(this.settingsSections.get(groupId)!, section);
280
+ this.fireDidSettingsChange();
281
+ return disposable;
282
+ }
283
+
284
+ visitSection(
285
+ section: ISettingSection,
286
+ cb: (v: IPreferenceViewDesc) => boolean | undefined,
287
+ ): IPreferenceViewDesc | undefined {
288
+ if (section.preferences) {
289
+ for (const preference of section.preferences) {
290
+ const result = cb(preference);
291
+ if (result) {
292
+ return preference;
293
+ }
294
+ }
295
+ }
296
+ if (section.subSections && Array.isArray(section.subSections)) {
297
+ for (const subSec of section.subSections) {
298
+ return this.visitSection(subSec, cb);
299
+ }
300
+ }
301
+ }
302
+
303
+ /**
304
+ * 通过配置项ID获取配置项展示信息
305
+ * @param preferenceId 配置项ID
306
+ */
307
+ getPreferenceViewDesc(preferenceId: string) {
308
+ const groups = this.settingsSections.values();
309
+ for (const sections of groups) {
310
+ for (const section of sections) {
311
+ const pref = this.visitSection(section, (preference) => {
312
+ if (!isString(preference)) {
313
+ if (preference.id === preferenceId) {
314
+ return true;
315
+ }
316
+ }
317
+ });
318
+ if (pref) {
319
+ return pref;
320
+ }
321
+ }
322
+ }
323
+ }
324
+
325
+ /**
326
+ * 获取特定作用域及搜索条件下的配置项
327
+ * @param groupId 配置组ID
328
+ * @param scope 作用域
329
+ * @param search 搜索条件
330
+ */
331
+ getResolvedSections(groupId: string, scope: PreferenceScope, search?: string): IResolvedSettingSection[] {
332
+ const key = [groupId, scope, search || ''].join('-');
333
+ if (this.cachedGroupSection.has(key)) {
334
+ return this.cachedGroupSection.get(key)!;
335
+ }
336
+ const res = (this.settingsSections.get(groupId) || []).filter((section) => {
337
+ if (section.hiddenInScope && section.hiddenInScope.indexOf(scope) >= 0) {
338
+ return false;
339
+ } else {
340
+ return true;
341
+ }
342
+ });
343
+
344
+ const result: IResolvedSettingSection[] = [];
345
+ const processSection = (section: Required<Pick<ISettingSection, 'preferences'>>) => {
346
+ const preferences = section.preferences
347
+ .filter((pref) => {
348
+ if (this.filterPreferences(pref, scope)) {
349
+ return false;
350
+ }
351
+ return true;
352
+ })
353
+ .map((pref) => {
354
+ const prefId = typeof pref === 'string' ? pref : pref.id;
355
+ const schema = this.schemaProvider.getPreferenceProperty(prefId);
356
+ const prefLabel = typeof pref === 'string' ? toPreferenceReadableName(pref) : getPreferenceItemLabel(pref);
357
+ const description = schema && replaceLocalizePlaceholder(schema.description);
358
+ const markdownDescription = schema && replaceLocalizePlaceholder(schema.markdownDescription);
359
+ return {
360
+ id: prefId,
361
+ label: prefLabel,
362
+ _description: markdownDescription ?? description,
363
+ markdownDescription,
364
+ description,
365
+ };
366
+ })
367
+ .filter((pref) => {
368
+ if (!search) {
369
+ return true;
370
+ }
371
+ return (
372
+ this.isContainSearchValue(pref.id, search) ||
373
+ this.isContainSearchValue(pref.label, search) ||
374
+ (pref.description && this.isContainSearchValue(pref.description, search)) ||
375
+ (pref.markdownDescription && this.isContainSearchValue(pref.markdownDescription, search))
376
+ );
377
+ }) as IResolvedPreferenceViewDesc[];
378
+
379
+ return {
380
+ preferences,
381
+ };
382
+ };
383
+ res.forEach((section) => {
384
+ const sec = { ...section } as IResolvedSettingSection;
385
+
386
+ if (section.preferences) {
387
+ const { preferences } = processSection(section as Required<Pick<ISettingSection, 'preferences'>>);
388
+ sec.preferences = preferences;
389
+ }
390
+ if (section.subSections) {
391
+ const subSections = section.subSections
392
+ .map((v) => {
393
+ const { preferences } = processSection(v as Required<Pick<ISettingSection, 'preferences'>>);
394
+ if (preferences.length > 0) {
395
+ return { ...v, preferences };
396
+ }
397
+ })
398
+ .filter(Boolean) as IResolvedSettingSection[];
399
+ sec.subSections = subSections;
400
+ }
401
+
402
+ if ((sec.preferences && sec.preferences.length > 0) || (sec.subSections && sec.subSections.length > 0)) {
403
+ result.push(sec);
404
+ }
405
+ });
406
+
407
+ this.cachedGroupSection.set(key.toLocaleLowerCase(), result);
408
+ return result;
409
+ }
410
+
411
+ /**
412
+ * 获取某个配置名在特定作用域下的值
413
+ * @param preferenceName 配置名
414
+ * @param scope 作用域
415
+ * @param inherited 是否继承低优先级的配置值
416
+ */
417
+ getPreference(
418
+ preferenceName: string,
419
+ scope: PreferenceScope,
420
+ inherited = false,
421
+ ): { value: any; effectingScope: PreferenceScope } {
422
+ const { value } = this.preferenceService.resolve(preferenceName, undefined, undefined, undefined, scope) || {
423
+ value: undefined,
424
+ scope: PreferenceScope.Default,
425
+ };
426
+ const { scope: effectingScope } = this.preferenceService.resolve(preferenceName) || {
427
+ value: undefined,
428
+ scope: PreferenceScope.Default,
429
+ };
430
+ return {
431
+ value,
432
+ effectingScope: effectingScope || PreferenceScope.Default,
433
+ };
434
+ }
435
+
436
+ /**
437
+ * 获取某个配置名下存在的Enum枚举项
438
+ * @param preferenceName 配置名
439
+ */
440
+ getEnumLabels(preferenceName: string): { [key: string]: string } {
441
+ return this.enumLabels.get(preferenceName) || {};
442
+ }
443
+
444
+ /**
445
+ * 设置某个配置名下的Enum枚举项
446
+ * @param preferenceName 配置名
447
+ * @param labels 枚举项
448
+ */
449
+ setEnumLabels(preferenceName: string, labels: { [key: string]: string }) {
450
+ if (this.enumLabelsChangeDelayer && !this.enumLabelsChangeDelayer.isTriggered()) {
451
+ this.enumLabelsChangeDelayer.cancel();
452
+ }
453
+ this.enumLabelsChangeDelayer.trigger(async () => {
454
+ this.onDidEnumLabelsChangeEmitter.fire();
455
+ });
456
+ this.enumLabels.set(preferenceName, labels);
457
+ }
458
+
459
+ /**
460
+ * 重置某个配置项在特定作用域下的值
461
+ * @param preferenceName 配置名
462
+ * @param scope 作用域
463
+ */
464
+ async reset(preferenceName: string, scope: PreferenceScope) {
465
+ await this.preferenceService.set(preferenceName, undefined, scope);
466
+ }
467
+
468
+ /**
469
+ * 获取特定作用域下的配置文件路径
470
+ * @param scope 作用域
471
+ */
472
+ async getPreferenceUrl(scope: PreferenceScope) {
473
+ const preferenceProvider: PreferenceProvider = this.providerProvider(scope);
474
+ const resource = await preferenceProvider.resource;
475
+
476
+ if (resource) {
477
+ return resource.uri;
478
+ } else {
479
+ return preferenceProvider.getConfigUri()?.toString();
480
+ }
481
+ }
482
+
483
+ /**
484
+ * 获取当前面板下对应的配置文件路径
485
+ * @param scope 作用域
486
+ */
487
+ async getCurrentPreferenceUrl(scope?: PreferenceScope) {
488
+ // 默认获取全局设置的URI
489
+ const url = await this.getPreferenceUrl(scope || this.currentScope || PreferenceScope.User);
490
+ if (!url) {
491
+ return;
492
+ }
493
+ const exist = await this.fileServiceClient.access(url);
494
+ if (!exist) {
495
+ const fileStat = await this.fileServiceClient.createFile(url);
496
+ if (fileStat) {
497
+ await this.fileServiceClient.setContent(fileStat!, '{\n}');
498
+ }
499
+ }
500
+ return url;
501
+ }
502
+
503
+ /**
504
+ * 在设置面板下搜索配置
505
+ * @param value 搜索值
506
+ */
507
+ search = (value: string) => {
508
+ this.doSearch(value);
509
+ };
510
+
511
+ private readonly _onFocus: Emitter<void> = new Emitter<void>();
512
+
513
+ get onFocus(): Event<void> {
514
+ return this._onFocus.event;
515
+ }
516
+
517
+ focusInput() {
518
+ this._onFocus.fire();
519
+ }
520
+ }
521
+
522
+ export const defaultSettingGroup: ISettingGroup[] = [
523
+ {
524
+ id: PreferenceSettingId.General,
525
+ title: '%settings.group.general%',
526
+ iconClass: getIcon('setting'),
527
+ },
528
+ {
529
+ id: PreferenceSettingId.Editor,
530
+ title: '%settings.group.editor%',
531
+ iconClass: getIcon('editor'),
532
+ },
533
+ {
534
+ id: PreferenceSettingId.View,
535
+ title: '%settings.group.view%',
536
+ iconClass: getIcon('detail'),
537
+ },
538
+ {
539
+ id: PreferenceSettingId.Terminal,
540
+ title: '%settings.group.terminal%',
541
+ iconClass: getIcon('terminal'),
542
+ },
543
+ {
544
+ id: PreferenceSettingId.Feature,
545
+ title: '%settings.group.feature%',
546
+ iconClass: getIcon('file-text'),
547
+ },
548
+ ];
549
+
550
+ export const defaultSettingSections: {
551
+ [key: string]: ISettingSection[];
552
+ } = {
553
+ [PreferenceSettingId.General]: [
554
+ {
555
+ preferences: [
556
+ { id: 'general.theme', localized: 'preference.general.theme' },
557
+ { id: 'general.icon', localized: 'preference.general.icon' },
558
+ {
559
+ id: 'general.language',
560
+ localized: 'preference.general.language',
561
+ hiddenInScope: [PreferenceScope.Workspace],
562
+ },
563
+ ],
564
+ },
565
+ ],
566
+ [PreferenceSettingId.Editor]: [
567
+ {
568
+ title: 'Editor',
569
+ preferences: [
570
+ // 预览模式
571
+ { id: 'editor.previewMode' },
572
+ {
573
+ id: 'editor.enablePreviewFromCodeNavigation',
574
+ },
575
+ // 自动保存
576
+ { id: 'editor.autoSave', localized: 'preference.editor.autoSave' },
577
+ { id: 'editor.autoSaveDelay', localized: 'preference.editor.autoSaveDelay' },
578
+ {
579
+ id: 'workbench.refactoringChanges.showPreviewStrategy',
580
+ localized: 'preference.workbench.refactoringChanges.showPreviewStrategy.title',
581
+ },
582
+ { id: 'editor.askIfDiff', localized: 'preference.editor.askIfDiff' },
583
+ // 光标样式
584
+ { id: 'editor.cursorStyle', localized: 'preference.editor.cursorStyle' },
585
+ // 字体
586
+ { id: 'editor.fontSize', localized: 'preference.editor.fontSize' },
587
+ { id: 'editor.fontWeight', localized: 'preference.editor.fontWeight' },
588
+ { id: 'editor.fontFamily', localized: 'preference.editor.fontFamily' },
589
+ { id: 'editor.lineHeight', localized: 'preference.editor.lineHeight' },
590
+ { id: 'editor.trimAutoWhitespace' },
591
+
592
+ // 补全
593
+ { id: 'editor.suggest.insertMode' },
594
+ { id: 'editor.suggest.filterGraceful' },
595
+ { id: 'editor.suggest.localityBonus' },
596
+ { id: 'editor.suggest.shareSuggestSelections' },
597
+ { id: 'editor.suggest.snippetsPreventQuickSuggestions' },
598
+ { id: 'editor.suggest.showIcons' },
599
+ { id: 'editor.suggest.maxVisibleSuggestions' },
600
+ { id: 'editor.suggest.showMethods' },
601
+ { id: 'editor.suggest.showFunctions' },
602
+ { id: 'editor.suggest.showConstructors' },
603
+ { id: 'editor.suggest.showFields' },
604
+ { id: 'editor.suggest.showVariables' },
605
+ { id: 'editor.suggest.showClasses' },
606
+ { id: 'editor.suggest.showStructs' },
607
+ { id: 'editor.suggest.showInterfaces' },
608
+ { id: 'editor.suggest.showModules' },
609
+ { id: 'editor.suggest.showProperties' },
610
+ { id: 'editor.suggest.showEvents' },
611
+ { id: 'editor.suggest.showOperators' },
612
+ { id: 'editor.suggest.showUnits' },
613
+ { id: 'editor.suggest.showValues' },
614
+ { id: 'editor.suggest.showConstants' },
615
+ { id: 'editor.suggest.showEnums' },
616
+ { id: 'editor.suggest.showEnumMembers' },
617
+ { id: 'editor.suggest.showKeywords' },
618
+ { id: 'editor.suggest.showWords' },
619
+ { id: 'editor.suggest.showColors' },
620
+ { id: 'editor.suggest.showFiles' },
621
+ { id: 'editor.suggest.showReferences' },
622
+ { id: 'editor.suggest.showCustomcolors' },
623
+ { id: 'editor.suggest.showFolders' },
624
+ { id: 'editor.suggest.showTypeParameters' },
625
+ { id: 'editor.suggest.showSnippets' },
626
+ { id: 'editor.suggest.showUsers' },
627
+ { id: 'editor.suggest.showIssues' },
628
+ { id: 'editor.suggest.preview' },
629
+ { id: 'editor.suggest.details.visible' },
630
+
631
+ // Guides
632
+ { id: 'editor.guides.bracketPairs', localized: 'preference.editor.guides.bracketPairs' },
633
+ { id: 'editor.guides.indentation', localized: 'preference.editor.guides.indentation' },
634
+ {
635
+ id: 'editor.guides.highlightActiveIndentation',
636
+ localized: 'preference.editor.guides.highlightActiveIndentation',
637
+ },
638
+
639
+ // 行内补全
640
+ { id: 'editor.inlineSuggest.enabled', localized: 'preference.editor.inlineSuggest.enabled' },
641
+ {
642
+ id: 'editor.experimental.stickyScroll.enabled',
643
+ localized: 'preference.editor.experimental.stickyScroll.enabled',
644
+ },
645
+ // 缩进
646
+ { id: 'editor.detectIndentation', localized: 'preference.editor.detectIndentation' },
647
+ { id: 'editor.tabSize', localized: 'preference.editor.tabSize' },
648
+ { id: 'editor.insertSpaces', localized: 'preference.editor.insertSpace' },
649
+ // 显示
650
+ { id: 'editor.wrapTab', localized: 'preference.editor.wrapTab' },
651
+ { id: 'editor.wordWrap', localized: 'preference.editor.wordWrap' },
652
+ { id: 'editor.renderLineHighlight', localized: 'preference.editor.renderLineHighlight' },
653
+ { id: 'editor.renderWhitespace', localized: 'preference.editor.renderWhitespace' },
654
+ { id: 'editor.minimap', localized: 'preference.editor.minimap' },
655
+ // 格式化
656
+ { id: 'editor.preferredFormatter', localized: 'preference.editor.preferredFormatter' },
657
+ { id: 'editor.formatOnSave', localized: 'preference.editor.formatOnSave' },
658
+ { id: 'editor.formatOnSaveTimeout', localized: 'preference.editor.formatOnSaveTimeout' },
659
+ { id: 'editor.formatOnPaste', localized: 'preference.editor.formatOnPaste' },
660
+ // 智能提示
661
+ { id: 'editor.quickSuggestionsDelay', localized: 'preference.editor.quickSuggestionsDelay' },
662
+ // 文件
663
+ // `forceReadOnly` 选项暂时不对用户暴露
664
+ // {id: 'editor.forceReadOnly', localized: 'preference.editor.forceReadOnly'},
665
+ { id: 'editor.maxTokenizationLineLength', localized: 'preference.editor.maxTokenizationLineLength' },
666
+ { id: 'editor.largeFile', localized: 'preference.editor.largeFile' },
667
+ { id: 'editor.readonlyFiles', localized: 'preference.editor.readonlyFiles' },
668
+ {
669
+ id: 'editor.bracketPairColorization.enabled',
670
+ localized: 'preference.editor.bracketPairColorization.enabled',
671
+ },
672
+ { id: 'workbench.editorAssociations' },
673
+ ],
674
+ },
675
+ {
676
+ title: 'Diff Editor',
677
+ preferences: [
678
+ // Diff 编辑器
679
+ { id: 'diffEditor.renderSideBySide', localized: 'preference.diffEditor.renderSideBySide' },
680
+ { id: 'diffEditor.ignoreTrimWhitespace', localized: 'preference.diffEditor.ignoreTrimWhitespace' },
681
+ ],
682
+ },
683
+ {
684
+ title: 'Files',
685
+ preferences: [
686
+ { id: 'files.autoGuessEncoding', localized: 'preference.files.autoGuessEncoding.title' },
687
+ { id: 'files.encoding', localized: 'preference.files.encoding.title' },
688
+ { id: 'files.eol' },
689
+ { id: 'files.trimFinalNewlines' },
690
+ { id: 'files.trimTrailingWhitespace' },
691
+ { id: 'files.insertFinalNewline' },
692
+ { id: 'files.exclude', localized: 'preference.files.exclude.title' },
693
+ { id: 'files.watcherExclude', localized: 'preference.files.watcherExclude.title' },
694
+ { id: 'files.associations', localized: 'preference.files.associations.title' },
695
+ ],
696
+ },
697
+ ],
698
+ // 整体布局相关的,比如 QuickOpen 也放这
699
+ [PreferenceSettingId.View]: [
700
+ {
701
+ // 布局信息
702
+ title: 'Layout',
703
+ preferences: [{ id: 'view.saveLayoutWithWorkspace', localized: 'preference.view.saveLayoutWithWorkspace.title' }],
704
+ },
705
+ {
706
+ title: 'File Tree',
707
+ preferences: [],
708
+ },
709
+ {
710
+ // 资源管理器
711
+ title: 'Explorer',
712
+ preferences: [
713
+ { id: 'explorer.fileTree.baseIndent', localized: 'preference.explorer.fileTree.baseIndent.title' },
714
+ { id: 'explorer.fileTree.indent', localized: 'preference.explorer.fileTree.indent.title' },
715
+ { id: 'explorer.compactFolders', localized: 'preference.explorer.compactFolders.title' },
716
+ { id: 'explorer.autoReveal', localized: 'preference.explorer.autoReveal' },
717
+ ],
718
+ },
719
+ {
720
+ title: 'QuickOpen',
721
+ preferences: [{ id: 'workbench.quickOpen.preserveInput' }],
722
+ },
723
+ {
724
+ title: 'Search',
725
+ preferences: [
726
+ // 搜索
727
+ { id: SearchSettingId.Include },
728
+ { id: SearchSettingId.Exclude, localized: 'preference.search.exclude.title' },
729
+ { id: SearchSettingId.UseReplacePreview },
730
+ // { id: 'search.maxResults' },
731
+ { id: SearchSettingId.SearchOnType },
732
+ { id: SearchSettingId.SearchOnTypeDebouncePeriod },
733
+ // { id: 'search.showLineNumbers' },
734
+ // { id: 'search.smartCase' },
735
+ // { id: 'search.useGlobalIgnoreFiles' },
736
+ // { id: 'search.useIgnoreFiles' },
737
+ // { id: 'search.useParentIgnoreFiles' },
738
+
739
+ // { id: 'search.quickOpen.includeHistory' },
740
+ // { id: 'search.quickOpen.includeSymbols' },
741
+ ],
742
+ },
743
+ {
744
+ title: 'Output',
745
+ preferences: [
746
+ // 输出
747
+ { id: 'output.maxChannelLine', localized: 'output.maxChannelLine' },
748
+ { id: 'output.enableLogHighlight', localized: 'output.enableLogHighlight' },
749
+ { id: 'output.enableSmartScroll', localized: 'output.enableSmartScroll' },
750
+ ],
751
+ },
752
+ {
753
+ title: 'Debug',
754
+ preferences: [
755
+ // 调试
756
+ // 由于筛选器的匹配模式搜索存在性能、匹配难度大等问题,先暂时隐藏
757
+ // { id: 'debug.console.filter.mode', localized: 'preference.debug.console.filter.mode' },
758
+ { id: 'debug.console.wordWrap', localized: 'preference.debug.console.wordWrap' },
759
+ { id: 'debug.inline.values', localized: 'preference.debug.inline.values' },
760
+ { id: 'debug.toolbar.float', localized: 'preference.debug.toolbar.float.title' },
761
+ ],
762
+ },
763
+ ],
764
+ [PreferenceSettingId.Terminal]: [
765
+ {
766
+ preferences: [
767
+ // 终端类型
768
+ { id: TerminalSettingsId.Type, localized: 'preference.terminal.type' },
769
+ // 字体
770
+ { id: TerminalSettingsId.FontFamily, localized: 'preference.terminal.fontFamily' },
771
+ { id: TerminalSettingsId.FontSize, localized: 'preference.terminal.fontSize' },
772
+ { id: TerminalSettingsId.FontWeight, localized: 'preference.terminal.fontWeight' },
773
+ { id: TerminalSettingsId.LineHeight, localized: 'preference.terminal.lineHeight' },
774
+ // 光标
775
+ { id: TerminalSettingsId.CursorBlink, localized: 'preference.terminal.cursorBlink' },
776
+ // 显示
777
+ { id: TerminalSettingsId.Scrollback, localized: 'preference.terminal.scrollback' },
778
+ // 命令行参数
779
+ { id: 'terminal.integrated.shellArgs.linux', localized: 'preference.terminal.integrated.shellArgs.linux' },
780
+ { id: 'terminal.integrated.copyOnSelection', localized: 'preference.terminal.integrated.copyOnSelection' },
781
+ // Local echo
782
+ { id: 'terminal.integrated.localEchoEnabled', localized: 'preference.terminal.integrated.localEchoEnabled' },
783
+ {
784
+ id: 'terminal.integrated.localEchoLatencyThreshold',
785
+ localized: 'preference.terminal.integrated.localEchoLatencyThreshold',
786
+ },
787
+ {
788
+ id: 'terminal.integrated.localEchoExcludePrograms',
789
+ localized: 'preference.terminal.integrated.localEchoExcludePrograms',
790
+ },
791
+ {
792
+ id: 'terminal.integrated.cursorStyle',
793
+ localized: 'preference.terminal.integrated.cursorStyle',
794
+ },
795
+ { id: 'terminal.integrated.localEchoStyle', localized: 'preference.terminal.integrated.localEchoStyle' },
796
+ ],
797
+ },
798
+ ],
799
+ [PreferenceSettingId.Feature]: [
800
+ {
801
+ title: 'Misc',
802
+ preferences: [],
803
+ },
804
+ {
805
+ // 树/列表项
806
+ title: 'Tree Component',
807
+ preferences: [{ id: 'workbench.list.openMode', localized: 'preference.workbench.list.openMode.title' }],
808
+ },
809
+ ],
810
+ };