@theia/editor 1.45.0 → 1.46.0-next.72

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 (112) hide show
  1. package/README.md +30 -30
  2. package/lib/browser/decorations/editor-decoration-style.d.ts +8 -8
  3. package/lib/browser/decorations/editor-decoration-style.js +36 -36
  4. package/lib/browser/decorations/editor-decoration.d.ts +106 -106
  5. package/lib/browser/decorations/editor-decoration.js +37 -37
  6. package/lib/browser/decorations/editor-decorator.d.ts +6 -6
  7. package/lib/browser/decorations/editor-decorator.js +43 -43
  8. package/lib/browser/decorations/index.d.ts +3 -3
  9. package/lib/browser/decorations/index.js +30 -30
  10. package/lib/browser/diff-navigator.d.ts +9 -10
  11. package/lib/browser/diff-navigator.d.ts.map +1 -1
  12. package/lib/browser/diff-navigator.js +19 -19
  13. package/lib/browser/diff-navigator.js.map +1 -1
  14. package/lib/browser/editor-command.d.ts +102 -102
  15. package/lib/browser/editor-command.js +426 -426
  16. package/lib/browser/editor-contribution.d.ts +26 -26
  17. package/lib/browser/editor-contribution.js +198 -198
  18. package/lib/browser/editor-frontend-module.d.ts +5 -5
  19. package/lib/browser/editor-frontend-module.js +74 -74
  20. package/lib/browser/editor-generated-preference-schema.d.ts +282 -249
  21. package/lib/browser/editor-generated-preference-schema.d.ts.map +1 -1
  22. package/lib/browser/editor-generated-preference-schema.js +2451 -2316
  23. package/lib/browser/editor-generated-preference-schema.js.map +1 -1
  24. package/lib/browser/editor-keybinding.d.ts +5 -5
  25. package/lib/browser/editor-keybinding.js +55 -55
  26. package/lib/browser/editor-linenumber-contribution.d.ts +15 -15
  27. package/lib/browser/editor-linenumber-contribution.d.ts.map +1 -1
  28. package/lib/browser/editor-linenumber-contribution.js +95 -96
  29. package/lib/browser/editor-linenumber-contribution.js.map +1 -1
  30. package/lib/browser/editor-manager.d.ts +115 -115
  31. package/lib/browser/editor-manager.js +428 -428
  32. package/lib/browser/editor-menu.d.ts +48 -48
  33. package/lib/browser/editor-menu.js +210 -210
  34. package/lib/browser/editor-navigation-contribution.d.ts +67 -67
  35. package/lib/browser/editor-navigation-contribution.js +343 -343
  36. package/lib/browser/editor-preferences.d.ts +41 -41
  37. package/lib/browser/editor-preferences.js +176 -176
  38. package/lib/browser/editor-variable-contribution.d.ts +8 -8
  39. package/lib/browser/editor-variable-contribution.js +64 -64
  40. package/lib/browser/editor-widget-factory.d.ts +17 -17
  41. package/lib/browser/editor-widget-factory.js +91 -91
  42. package/lib/browser/editor-widget.d.ts +24 -24
  43. package/lib/browser/editor-widget.d.ts.map +1 -1
  44. package/lib/browser/editor-widget.js +122 -114
  45. package/lib/browser/editor-widget.js.map +1 -1
  46. package/lib/browser/editor.d.ts +295 -293
  47. package/lib/browser/editor.d.ts.map +1 -1
  48. package/lib/browser/editor.js +103 -103
  49. package/lib/browser/editor.js.map +1 -1
  50. package/lib/browser/index.d.ts +10 -10
  51. package/lib/browser/index.js +37 -37
  52. package/lib/browser/language-status/editor-language-status-service.d.ts +77 -77
  53. package/lib/browser/language-status/editor-language-status-service.js +251 -251
  54. package/lib/browser/navigation/navigation-location-service.d.ts +103 -103
  55. package/lib/browser/navigation/navigation-location-service.js +281 -281
  56. package/lib/browser/navigation/navigation-location-service.spec.d.ts +1 -1
  57. package/lib/browser/navigation/navigation-location-service.spec.js +184 -184
  58. package/lib/browser/navigation/navigation-location-similarity.d.ts +15 -15
  59. package/lib/browser/navigation/navigation-location-similarity.js +62 -62
  60. package/lib/browser/navigation/navigation-location-similarity.spec.d.ts +1 -1
  61. package/lib/browser/navigation/navigation-location-similarity.spec.js +32 -32
  62. package/lib/browser/navigation/navigation-location-updater.d.ts +35 -35
  63. package/lib/browser/navigation/navigation-location-updater.js +210 -210
  64. package/lib/browser/navigation/navigation-location-updater.spec.d.ts +1 -1
  65. package/lib/browser/navigation/navigation-location-updater.spec.js +177 -177
  66. package/lib/browser/navigation/navigation-location.d.ts +191 -191
  67. package/lib/browser/navigation/navigation-location.js +300 -300
  68. package/lib/browser/navigation/test/mock-navigation-location-updater.d.ts +15 -15
  69. package/lib/browser/navigation/test/mock-navigation-location-updater.js +38 -38
  70. package/lib/browser/quick-editor-service.d.ts +16 -16
  71. package/lib/browser/quick-editor-service.js +109 -109
  72. package/lib/browser/undo-redo-service.d.ts +23 -23
  73. package/lib/browser/undo-redo-service.js +110 -110
  74. package/lib/common/language-selector.d.ts +13 -13
  75. package/lib/common/language-selector.js +90 -90
  76. package/lib/package.spec.js +25 -25
  77. package/package.json +5 -5
  78. package/src/browser/decorations/editor-decoration-style.ts +41 -41
  79. package/src/browser/decorations/editor-decoration.ts +127 -127
  80. package/src/browser/decorations/editor-decorator.ts +36 -36
  81. package/src/browser/decorations/index.ts +19 -19
  82. package/src/browser/diff-navigator.ts +27 -28
  83. package/src/browser/editor-command.ts +414 -414
  84. package/src/browser/editor-contribution.ts +185 -185
  85. package/src/browser/editor-frontend-module.ts +87 -87
  86. package/src/browser/editor-generated-preference-schema.ts +2707 -2539
  87. package/src/browser/editor-keybinding.ts +55 -55
  88. package/src/browser/editor-linenumber-contribution.ts +88 -89
  89. package/src/browser/editor-manager.ts +442 -442
  90. package/src/browser/editor-menu.ts +224 -224
  91. package/src/browser/editor-navigation-contribution.ts +343 -343
  92. package/src/browser/editor-preferences.ts +226 -226
  93. package/src/browser/editor-variable-contribution.ts +54 -54
  94. package/src/browser/editor-widget-factory.ts +82 -82
  95. package/src/browser/editor-widget.ts +137 -130
  96. package/src/browser/editor.ts +360 -358
  97. package/src/browser/index.ts +26 -26
  98. package/src/browser/language-status/editor-language-status-service.ts +271 -271
  99. package/src/browser/language-status/editor-language-status.css +101 -101
  100. package/src/browser/navigation/navigation-location-service.spec.ts +245 -245
  101. package/src/browser/navigation/navigation-location-service.ts +284 -284
  102. package/src/browser/navigation/navigation-location-similarity.spec.ts +46 -46
  103. package/src/browser/navigation/navigation-location-similarity.ts +58 -58
  104. package/src/browser/navigation/navigation-location-updater.spec.ts +197 -197
  105. package/src/browser/navigation/navigation-location-updater.ts +220 -220
  106. package/src/browser/navigation/navigation-location.ts +418 -418
  107. package/src/browser/navigation/test/mock-navigation-location-updater.ts +41 -41
  108. package/src/browser/quick-editor-service.ts +94 -94
  109. package/src/browser/style/index.css +19 -19
  110. package/src/browser/undo-redo-service.ts +120 -120
  111. package/src/common/language-selector.ts +104 -104
  112. package/src/package.spec.ts +28 -28
@@ -1,226 +1,226 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 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 { interfaces } from '@theia/core/shared/inversify';
18
- import {
19
- createPreferenceProxy,
20
- PreferenceProxy,
21
- PreferenceService,
22
- PreferenceContribution,
23
- PreferenceSchema,
24
- PreferenceChangeEvent,
25
- PreferenceScope,
26
- } from '@theia/core/lib/browser/preferences';
27
- import { PreferenceProxyFactory } from '@theia/core/lib/browser/preferences/injectable-preference-proxy';
28
- import { nls } from '@theia/core/lib/common/nls';
29
- import { environment } from '@theia/core';
30
- import { editorGeneratedPreferenceProperties, GeneratedEditorPreferences } from './editor-generated-preference-schema';
31
-
32
- /* eslint-disable @theia/localization-check,max-len,no-null/no-null */
33
- // #region src/vs/workbench/contrib/codeActions/browser/codeActionsContribution.ts
34
-
35
- const codeActionsContributionSchema: PreferenceSchema['properties'] = {
36
- 'editor.codeActionsOnSave': {
37
- oneOf: [
38
- {
39
- type: 'object',
40
- properties: {
41
- 'source.fixAll': {
42
- type: 'boolean',
43
- description: nls.localizeByDefault('Controls whether auto fix action should be run on file save.')
44
- }
45
- },
46
- additionalProperties: {
47
- type: 'boolean'
48
- },
49
- },
50
- {
51
- type: 'array',
52
- items: { type: 'string' }
53
- }
54
- ],
55
- default: {},
56
- description: nls.localizeByDefault('Code action kinds to be run on save.'),
57
- scope: 'language-overridable',
58
- }
59
- };
60
-
61
- interface CodeActionsContributionProperties {
62
- 'editor.codeActionsOnSave': string[] | ({ 'source.fixAll': boolean } & Record<string, boolean>)
63
- }
64
-
65
- // #endregion
66
-
67
- // #region src/vs/workbench/contrib/files/browser/files.contribution.ts
68
- const fileContributionSchema: PreferenceSchema['properties'] = {
69
- 'editor.formatOnSave': {
70
- 'type': 'boolean',
71
- 'description': nls.localizeByDefault('Format a file on save. A formatter must be available, the file must not be saved after delay, and the editor must not be shutting down.'),
72
- 'scope': PreferenceScope.fromString('language-overridable'),
73
- },
74
- 'editor.formatOnSaveMode': {
75
- 'type': 'string',
76
- 'default': 'file',
77
- 'enum': [
78
- 'file',
79
- 'modifications',
80
- 'modificationsIfAvailable'
81
- ],
82
- 'enumDescriptions': [
83
- nls.localizeByDefault('Format the whole file.'),
84
- nls.localizeByDefault('Format modifications (requires source control).'),
85
- nls.localize('theia/editor/editor.formatOnSaveMode.modificationsIfAvailable', "Will attempt to format modifications only (requires source control). If source control can't be used, then the whole file will be formatted."),
86
- ],
87
- 'markdownDescription': nls.localizeByDefault('Controls if format on save formats the whole file or only modifications. Only applies when `#editor.formatOnSave#` is enabled.'),
88
- 'scope': PreferenceScope.fromString('language-overridable'),
89
- },
90
- // Include this, even though it is not strictly an `editor`preference.
91
- 'files.eol': {
92
- 'type': 'string',
93
- 'enum': [
94
- '\n',
95
- '\r\n',
96
- 'auto'
97
- ],
98
- 'enumDescriptions': [
99
- nls.localizeByDefault('LF'),
100
- nls.localizeByDefault('CRLF'),
101
- nls.localizeByDefault('Uses operating system specific end of line character.')
102
- ],
103
- 'default': 'auto',
104
- 'description': nls.localizeByDefault('The default end of line character.'),
105
- 'scope': PreferenceScope.fromString('language-overridable')
106
- },
107
- // We used to call these `editor.autoSave` and `editor.autoSaveDelay`.
108
- 'files.autoSave': {
109
- 'type': 'string',
110
- 'enum': ['off', 'afterDelay', 'onFocusChange', 'onWindowChange'],
111
- 'markdownEnumDescriptions': [
112
- nls.localize('theia/editor/files.autoSave.off', 'An editor with changes is never automatically saved.'),
113
- nls.localize('theia/editor/files.autoSave.afterDelay', 'An editor with changes is automatically saved after the configured `#files.autoSaveDelay#`.'),
114
- nls.localize('theia/editor/files.autoSave.onFocusChange', 'An editor with changes is automatically saved when the editor loses focus.'),
115
- nls.localize('theia/editor/files.autoSave.onWindowChange', 'An editor with changes is automatically saved when the window loses focus.')
116
- ],
117
- 'default': environment.electron.is() ? 'off' : 'afterDelay',
118
- 'markdownDescription': nls.localize('theia/editor/files.autoSave', 'Controls [auto save](https://code.visualstudio.com/docs/editor/codebasics#_save-auto-save) of editors that have unsaved changes.', 'off', 'afterDelay', 'onFocusChange', 'onWindowChange', 'afterDelay')
119
- },
120
- 'files.autoSaveDelay': {
121
- 'type': 'number',
122
- 'default': 1000,
123
- 'minimum': 0,
124
- 'markdownDescription': nls.localizeByDefault('Controls the delay in milliseconds after which an editor with unsaved changes is saved automatically. Only applies when `#files.autoSave#` is set to `{0}`.', 'afterDelay')
125
- },
126
- 'files.refactoring.autoSave': {
127
- 'type': 'boolean',
128
- 'default': true,
129
- 'description': nls.localizeByDefault('Controls if files that were part of a refactoring are saved automatically')
130
- }
131
- };
132
-
133
- interface FileContributionEditorPreferences {
134
- 'editor.formatOnSave': boolean;
135
- 'editor.formatOnSaveMode': 'file' | 'modifications' | 'modificationsIfAvailable';
136
- 'files.eol': '\n' | '\r\n' | 'auto';
137
- 'files.autoSave': 'off' | 'afterDelay' | 'onFocusChange' | 'onWindowChange';
138
- 'files.autoSaveDelay': number;
139
- 'files.refactoring.autoSave': boolean
140
- }
141
- // #endregion
142
-
143
- // #region src/vs/workbench/contrib/format/browser/formatActionsMultiple.ts
144
- // This schema depends on a lot of private stuff in the file, so this is a stripped down version.
145
- const formatActionsMultipleSchema: PreferenceSchema['properties'] = {
146
- 'editor.defaultFormatter': {
147
- description: nls.localizeByDefault('Defines a default formatter which takes precedence over all other formatter settings. Must be the identifier of an extension contributing a formatter.'),
148
- type: ['string', 'null'],
149
- default: null,
150
- }
151
- };
152
- interface FormatActionsMultipleProperties {
153
- 'editor.defaultFormatter': string | null;
154
- }
155
- // #endregion
156
-
157
- // #region Custom Theia extensions to editor preferences
158
-
159
- const theiaEditorSchema: PreferenceSchema['properties'] = {
160
- 'editor.formatOnSaveTimeout': {
161
- 'type': 'number',
162
- 'default': 750,
163
- 'description': nls.localize('theia/editor/formatOnSaveTimeout', 'Timeout in milliseconds after which the formatting that is run on file save is cancelled.')
164
- },
165
- 'editor.history.persistClosedEditors': {
166
- 'type': 'boolean',
167
- 'default': false,
168
- 'description': nls.localize('theia/editor/persistClosedEditors', 'Controls whether to persist closed editor history for the workspace across window reloads.')
169
- },
170
- };
171
-
172
- interface TheiaEditorProperties {
173
- 'editor.formatOnSaveTimeout': number;
174
- 'editor.history.persistClosedEditors': boolean;
175
- }
176
-
177
- // #endregion
178
-
179
- const combinedProperties = {
180
- ...editorGeneratedPreferenceProperties,
181
- ...codeActionsContributionSchema,
182
- ...fileContributionSchema,
183
- ...formatActionsMultipleSchema,
184
- ...theiaEditorSchema
185
- };
186
-
187
- export const editorPreferenceSchema: PreferenceSchema = {
188
- 'type': 'object',
189
- 'scope': 'resource',
190
- 'overridable': true,
191
- 'properties': combinedProperties,
192
- };
193
-
194
- export interface EditorConfiguration extends GeneratedEditorPreferences,
195
- CodeActionsContributionProperties,
196
- FileContributionEditorPreferences,
197
- FormatActionsMultipleProperties,
198
- TheiaEditorProperties { }
199
-
200
- export type EndOfLinePreference = '\n' | '\r\n' | 'auto';
201
-
202
- export type EditorPreferenceChange = PreferenceChangeEvent<EditorConfiguration>;
203
-
204
- export const EditorPreferenceContribution = Symbol('EditorPreferenceContribution');
205
- export const EditorPreferences = Symbol('EditorPreferences');
206
- export type EditorPreferences = PreferenceProxy<EditorConfiguration>;
207
-
208
- /**
209
- * @deprecated @since 1.23.0
210
- *
211
- * By default, editor preferences now use a validated preference proxy created by the PreferenceProxyFactory binding.
212
- * This function will create an unvalidated preference proxy.
213
- * See {@link bindEditorPreferences}
214
- */
215
- export function createEditorPreferences(preferences: PreferenceService, schema: PreferenceSchema = editorPreferenceSchema): EditorPreferences {
216
- return createPreferenceProxy(preferences, schema);
217
- }
218
-
219
- export function bindEditorPreferences(bind: interfaces.Bind): void {
220
- bind(EditorPreferences).toDynamicValue(ctx => {
221
- const factory = ctx.container.get<PreferenceProxyFactory>(PreferenceProxyFactory);
222
- return factory(editorPreferenceSchema);
223
- }).inSingletonScope();
224
- bind(EditorPreferenceContribution).toConstantValue({ schema: editorPreferenceSchema });
225
- bind(PreferenceContribution).toService(EditorPreferenceContribution);
226
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 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 { interfaces } from '@theia/core/shared/inversify';
18
+ import {
19
+ createPreferenceProxy,
20
+ PreferenceProxy,
21
+ PreferenceService,
22
+ PreferenceContribution,
23
+ PreferenceSchema,
24
+ PreferenceChangeEvent,
25
+ PreferenceScope,
26
+ } from '@theia/core/lib/browser/preferences';
27
+ import { PreferenceProxyFactory } from '@theia/core/lib/browser/preferences/injectable-preference-proxy';
28
+ import { nls } from '@theia/core/lib/common/nls';
29
+ import { environment } from '@theia/core';
30
+ import { editorGeneratedPreferenceProperties, GeneratedEditorPreferences } from './editor-generated-preference-schema';
31
+
32
+ /* eslint-disable @theia/localization-check,max-len,no-null/no-null */
33
+ // #region src/vs/workbench/contrib/codeActions/browser/codeActionsContribution.ts
34
+
35
+ const codeActionsContributionSchema: PreferenceSchema['properties'] = {
36
+ 'editor.codeActionsOnSave': {
37
+ oneOf: [
38
+ {
39
+ type: 'object',
40
+ properties: {
41
+ 'source.fixAll': {
42
+ type: 'boolean',
43
+ description: nls.localizeByDefault('Controls whether auto fix action should be run on file save.')
44
+ }
45
+ },
46
+ additionalProperties: {
47
+ type: 'boolean'
48
+ },
49
+ },
50
+ {
51
+ type: 'array',
52
+ items: { type: 'string' }
53
+ }
54
+ ],
55
+ default: {},
56
+ description: nls.localizeByDefault('Code action kinds to be run on save.'),
57
+ scope: 'language-overridable',
58
+ }
59
+ };
60
+
61
+ interface CodeActionsContributionProperties {
62
+ 'editor.codeActionsOnSave': string[] | ({ 'source.fixAll': boolean } & Record<string, boolean>)
63
+ }
64
+
65
+ // #endregion
66
+
67
+ // #region src/vs/workbench/contrib/files/browser/files.contribution.ts
68
+ const fileContributionSchema: PreferenceSchema['properties'] = {
69
+ 'editor.formatOnSave': {
70
+ 'type': 'boolean',
71
+ 'description': nls.localizeByDefault('Format a file on save. A formatter must be available, the file must not be saved after delay, and the editor must not be shutting down.'),
72
+ 'scope': PreferenceScope.fromString('language-overridable'),
73
+ },
74
+ 'editor.formatOnSaveMode': {
75
+ 'type': 'string',
76
+ 'default': 'file',
77
+ 'enum': [
78
+ 'file',
79
+ 'modifications',
80
+ 'modificationsIfAvailable'
81
+ ],
82
+ 'enumDescriptions': [
83
+ nls.localizeByDefault('Format the whole file.'),
84
+ nls.localizeByDefault('Format modifications (requires source control).'),
85
+ nls.localize('theia/editor/editor.formatOnSaveMode.modificationsIfAvailable', "Will attempt to format modifications only (requires source control). If source control can't be used, then the whole file will be formatted."),
86
+ ],
87
+ 'markdownDescription': nls.localizeByDefault('Controls if format on save formats the whole file or only modifications. Only applies when `#editor.formatOnSave#` is enabled.'),
88
+ 'scope': PreferenceScope.fromString('language-overridable'),
89
+ },
90
+ // Include this, even though it is not strictly an `editor`preference.
91
+ 'files.eol': {
92
+ 'type': 'string',
93
+ 'enum': [
94
+ '\n',
95
+ '\r\n',
96
+ 'auto'
97
+ ],
98
+ 'enumDescriptions': [
99
+ nls.localizeByDefault('LF'),
100
+ nls.localizeByDefault('CRLF'),
101
+ nls.localizeByDefault('Uses operating system specific end of line character.')
102
+ ],
103
+ 'default': 'auto',
104
+ 'description': nls.localizeByDefault('The default end of line character.'),
105
+ 'scope': PreferenceScope.fromString('language-overridable')
106
+ },
107
+ // We used to call these `editor.autoSave` and `editor.autoSaveDelay`.
108
+ 'files.autoSave': {
109
+ 'type': 'string',
110
+ 'enum': ['off', 'afterDelay', 'onFocusChange', 'onWindowChange'],
111
+ 'markdownEnumDescriptions': [
112
+ nls.localize('theia/editor/files.autoSave.off', 'An editor with changes is never automatically saved.'),
113
+ nls.localize('theia/editor/files.autoSave.afterDelay', 'An editor with changes is automatically saved after the configured `#files.autoSaveDelay#`.'),
114
+ nls.localize('theia/editor/files.autoSave.onFocusChange', 'An editor with changes is automatically saved when the editor loses focus.'),
115
+ nls.localize('theia/editor/files.autoSave.onWindowChange', 'An editor with changes is automatically saved when the window loses focus.')
116
+ ],
117
+ 'default': environment.electron.is() ? 'off' : 'afterDelay',
118
+ 'markdownDescription': nls.localize('theia/editor/files.autoSave', 'Controls [auto save](https://code.visualstudio.com/docs/editor/codebasics#_save-auto-save) of editors that have unsaved changes.', 'off', 'afterDelay', 'onFocusChange', 'onWindowChange', 'afterDelay')
119
+ },
120
+ 'files.autoSaveDelay': {
121
+ 'type': 'number',
122
+ 'default': 1000,
123
+ 'minimum': 0,
124
+ 'markdownDescription': nls.localizeByDefault('Controls the delay in milliseconds after which an editor with unsaved changes is saved automatically. Only applies when `#files.autoSave#` is set to `{0}`.', 'afterDelay')
125
+ },
126
+ 'files.refactoring.autoSave': {
127
+ 'type': 'boolean',
128
+ 'default': true,
129
+ 'description': nls.localizeByDefault('Controls if files that were part of a refactoring are saved automatically')
130
+ }
131
+ };
132
+
133
+ interface FileContributionEditorPreferences {
134
+ 'editor.formatOnSave': boolean;
135
+ 'editor.formatOnSaveMode': 'file' | 'modifications' | 'modificationsIfAvailable';
136
+ 'files.eol': '\n' | '\r\n' | 'auto';
137
+ 'files.autoSave': 'off' | 'afterDelay' | 'onFocusChange' | 'onWindowChange';
138
+ 'files.autoSaveDelay': number;
139
+ 'files.refactoring.autoSave': boolean
140
+ }
141
+ // #endregion
142
+
143
+ // #region src/vs/workbench/contrib/format/browser/formatActionsMultiple.ts
144
+ // This schema depends on a lot of private stuff in the file, so this is a stripped down version.
145
+ const formatActionsMultipleSchema: PreferenceSchema['properties'] = {
146
+ 'editor.defaultFormatter': {
147
+ description: nls.localizeByDefault('Defines a default formatter which takes precedence over all other formatter settings. Must be the identifier of an extension contributing a formatter.'),
148
+ type: ['string', 'null'],
149
+ default: null,
150
+ }
151
+ };
152
+ interface FormatActionsMultipleProperties {
153
+ 'editor.defaultFormatter': string | null;
154
+ }
155
+ // #endregion
156
+
157
+ // #region Custom Theia extensions to editor preferences
158
+
159
+ const theiaEditorSchema: PreferenceSchema['properties'] = {
160
+ 'editor.formatOnSaveTimeout': {
161
+ 'type': 'number',
162
+ 'default': 750,
163
+ 'description': nls.localize('theia/editor/formatOnSaveTimeout', 'Timeout in milliseconds after which the formatting that is run on file save is cancelled.')
164
+ },
165
+ 'editor.history.persistClosedEditors': {
166
+ 'type': 'boolean',
167
+ 'default': false,
168
+ 'description': nls.localize('theia/editor/persistClosedEditors', 'Controls whether to persist closed editor history for the workspace across window reloads.')
169
+ },
170
+ };
171
+
172
+ interface TheiaEditorProperties {
173
+ 'editor.formatOnSaveTimeout': number;
174
+ 'editor.history.persistClosedEditors': boolean;
175
+ }
176
+
177
+ // #endregion
178
+
179
+ const combinedProperties = {
180
+ ...editorGeneratedPreferenceProperties,
181
+ ...codeActionsContributionSchema,
182
+ ...fileContributionSchema,
183
+ ...formatActionsMultipleSchema,
184
+ ...theiaEditorSchema
185
+ };
186
+
187
+ export const editorPreferenceSchema: PreferenceSchema = {
188
+ 'type': 'object',
189
+ 'scope': 'resource',
190
+ 'overridable': true,
191
+ 'properties': combinedProperties,
192
+ };
193
+
194
+ export interface EditorConfiguration extends GeneratedEditorPreferences,
195
+ CodeActionsContributionProperties,
196
+ FileContributionEditorPreferences,
197
+ FormatActionsMultipleProperties,
198
+ TheiaEditorProperties { }
199
+
200
+ export type EndOfLinePreference = '\n' | '\r\n' | 'auto';
201
+
202
+ export type EditorPreferenceChange = PreferenceChangeEvent<EditorConfiguration>;
203
+
204
+ export const EditorPreferenceContribution = Symbol('EditorPreferenceContribution');
205
+ export const EditorPreferences = Symbol('EditorPreferences');
206
+ export type EditorPreferences = PreferenceProxy<EditorConfiguration>;
207
+
208
+ /**
209
+ * @deprecated @since 1.23.0
210
+ *
211
+ * By default, editor preferences now use a validated preference proxy created by the PreferenceProxyFactory binding.
212
+ * This function will create an unvalidated preference proxy.
213
+ * See {@link bindEditorPreferences}
214
+ */
215
+ export function createEditorPreferences(preferences: PreferenceService, schema: PreferenceSchema = editorPreferenceSchema): EditorPreferences {
216
+ return createPreferenceProxy(preferences, schema);
217
+ }
218
+
219
+ export function bindEditorPreferences(bind: interfaces.Bind): void {
220
+ bind(EditorPreferences).toDynamicValue(ctx => {
221
+ const factory = ctx.container.get<PreferenceProxyFactory>(PreferenceProxyFactory);
222
+ return factory(editorPreferenceSchema);
223
+ }).inSingletonScope();
224
+ bind(EditorPreferenceContribution).toConstantValue({ schema: editorPreferenceSchema });
225
+ bind(PreferenceContribution).toService(EditorPreferenceContribution);
226
+ }
@@ -1,54 +1,54 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 Red Hat, Inc. 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 { injectable, inject } from '@theia/core/shared/inversify';
18
- import { VariableRegistry, VariableContribution } from '@theia/variable-resolver/lib/browser';
19
- import { TextEditor } from './editor';
20
- import { EditorManager } from './editor-manager';
21
-
22
- @injectable()
23
- export class EditorVariableContribution implements VariableContribution {
24
-
25
- @inject(EditorManager)
26
- protected readonly editorManager: EditorManager;
27
-
28
- registerVariables(variables: VariableRegistry): void {
29
- variables.registerVariable({
30
- name: 'lineNumber',
31
- description: 'The current line number in the currently opened file',
32
- resolve: () => {
33
- const editor = this.getCurrentEditor();
34
- return editor ? `${editor.cursor.line + 1}` : undefined;
35
- }
36
- });
37
- variables.registerVariable({
38
- name: 'selectedText',
39
- description: 'The current selected text in the active file',
40
- resolve: () => {
41
- const editor = this.getCurrentEditor();
42
- return editor ? editor.document.getText(editor.selection) : undefined;
43
- }
44
- });
45
- }
46
-
47
- protected getCurrentEditor(): TextEditor | undefined {
48
- const currentEditor = this.editorManager.currentEditor;
49
- if (!currentEditor) {
50
- return undefined;
51
- }
52
- return currentEditor.editor;
53
- }
54
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 Red Hat, Inc. 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 { injectable, inject } from '@theia/core/shared/inversify';
18
+ import { VariableRegistry, VariableContribution } from '@theia/variable-resolver/lib/browser';
19
+ import { TextEditor } from './editor';
20
+ import { EditorManager } from './editor-manager';
21
+
22
+ @injectable()
23
+ export class EditorVariableContribution implements VariableContribution {
24
+
25
+ @inject(EditorManager)
26
+ protected readonly editorManager: EditorManager;
27
+
28
+ registerVariables(variables: VariableRegistry): void {
29
+ variables.registerVariable({
30
+ name: 'lineNumber',
31
+ description: 'The current line number in the currently opened file',
32
+ resolve: () => {
33
+ const editor = this.getCurrentEditor();
34
+ return editor ? `${editor.cursor.line + 1}` : undefined;
35
+ }
36
+ });
37
+ variables.registerVariable({
38
+ name: 'selectedText',
39
+ description: 'The current selected text in the active file',
40
+ resolve: () => {
41
+ const editor = this.getCurrentEditor();
42
+ return editor ? editor.document.getText(editor.selection) : undefined;
43
+ }
44
+ });
45
+ }
46
+
47
+ protected getCurrentEditor(): TextEditor | undefined {
48
+ const currentEditor = this.editorManager.currentEditor;
49
+ if (!currentEditor) {
50
+ return undefined;
51
+ }
52
+ return currentEditor.editor;
53
+ }
54
+ }