@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.
- package/README.md +30 -30
- package/lib/browser/decorations/editor-decoration-style.d.ts +8 -8
- package/lib/browser/decorations/editor-decoration-style.js +36 -36
- package/lib/browser/decorations/editor-decoration.d.ts +106 -106
- package/lib/browser/decorations/editor-decoration.js +37 -37
- package/lib/browser/decorations/editor-decorator.d.ts +6 -6
- package/lib/browser/decorations/editor-decorator.js +43 -43
- package/lib/browser/decorations/index.d.ts +3 -3
- package/lib/browser/decorations/index.js +30 -30
- package/lib/browser/diff-navigator.d.ts +9 -10
- package/lib/browser/diff-navigator.d.ts.map +1 -1
- package/lib/browser/diff-navigator.js +19 -19
- package/lib/browser/diff-navigator.js.map +1 -1
- package/lib/browser/editor-command.d.ts +102 -102
- package/lib/browser/editor-command.js +426 -426
- package/lib/browser/editor-contribution.d.ts +26 -26
- package/lib/browser/editor-contribution.js +198 -198
- package/lib/browser/editor-frontend-module.d.ts +5 -5
- package/lib/browser/editor-frontend-module.js +74 -74
- package/lib/browser/editor-generated-preference-schema.d.ts +282 -249
- package/lib/browser/editor-generated-preference-schema.d.ts.map +1 -1
- package/lib/browser/editor-generated-preference-schema.js +2451 -2316
- package/lib/browser/editor-generated-preference-schema.js.map +1 -1
- package/lib/browser/editor-keybinding.d.ts +5 -5
- package/lib/browser/editor-keybinding.js +55 -55
- package/lib/browser/editor-linenumber-contribution.d.ts +15 -15
- package/lib/browser/editor-linenumber-contribution.d.ts.map +1 -1
- package/lib/browser/editor-linenumber-contribution.js +95 -96
- package/lib/browser/editor-linenumber-contribution.js.map +1 -1
- package/lib/browser/editor-manager.d.ts +115 -115
- package/lib/browser/editor-manager.js +428 -428
- package/lib/browser/editor-menu.d.ts +48 -48
- package/lib/browser/editor-menu.js +210 -210
- package/lib/browser/editor-navigation-contribution.d.ts +67 -67
- package/lib/browser/editor-navigation-contribution.js +343 -343
- package/lib/browser/editor-preferences.d.ts +41 -41
- package/lib/browser/editor-preferences.js +176 -176
- package/lib/browser/editor-variable-contribution.d.ts +8 -8
- package/lib/browser/editor-variable-contribution.js +64 -64
- package/lib/browser/editor-widget-factory.d.ts +17 -17
- package/lib/browser/editor-widget-factory.js +91 -91
- package/lib/browser/editor-widget.d.ts +24 -24
- package/lib/browser/editor-widget.d.ts.map +1 -1
- package/lib/browser/editor-widget.js +122 -114
- package/lib/browser/editor-widget.js.map +1 -1
- package/lib/browser/editor.d.ts +295 -293
- package/lib/browser/editor.d.ts.map +1 -1
- package/lib/browser/editor.js +103 -103
- package/lib/browser/editor.js.map +1 -1
- package/lib/browser/index.d.ts +10 -10
- package/lib/browser/index.js +37 -37
- package/lib/browser/language-status/editor-language-status-service.d.ts +77 -77
- package/lib/browser/language-status/editor-language-status-service.js +251 -251
- package/lib/browser/navigation/navigation-location-service.d.ts +103 -103
- package/lib/browser/navigation/navigation-location-service.js +281 -281
- package/lib/browser/navigation/navigation-location-service.spec.d.ts +1 -1
- package/lib/browser/navigation/navigation-location-service.spec.js +184 -184
- package/lib/browser/navigation/navigation-location-similarity.d.ts +15 -15
- package/lib/browser/navigation/navigation-location-similarity.js +62 -62
- package/lib/browser/navigation/navigation-location-similarity.spec.d.ts +1 -1
- package/lib/browser/navigation/navigation-location-similarity.spec.js +32 -32
- package/lib/browser/navigation/navigation-location-updater.d.ts +35 -35
- package/lib/browser/navigation/navigation-location-updater.js +210 -210
- package/lib/browser/navigation/navigation-location-updater.spec.d.ts +1 -1
- package/lib/browser/navigation/navigation-location-updater.spec.js +177 -177
- package/lib/browser/navigation/navigation-location.d.ts +191 -191
- package/lib/browser/navigation/navigation-location.js +300 -300
- package/lib/browser/navigation/test/mock-navigation-location-updater.d.ts +15 -15
- package/lib/browser/navigation/test/mock-navigation-location-updater.js +38 -38
- package/lib/browser/quick-editor-service.d.ts +16 -16
- package/lib/browser/quick-editor-service.js +109 -109
- package/lib/browser/undo-redo-service.d.ts +23 -23
- package/lib/browser/undo-redo-service.js +110 -110
- package/lib/common/language-selector.d.ts +13 -13
- package/lib/common/language-selector.js +90 -90
- package/lib/package.spec.js +25 -25
- package/package.json +5 -5
- package/src/browser/decorations/editor-decoration-style.ts +41 -41
- package/src/browser/decorations/editor-decoration.ts +127 -127
- package/src/browser/decorations/editor-decorator.ts +36 -36
- package/src/browser/decorations/index.ts +19 -19
- package/src/browser/diff-navigator.ts +27 -28
- package/src/browser/editor-command.ts +414 -414
- package/src/browser/editor-contribution.ts +185 -185
- package/src/browser/editor-frontend-module.ts +87 -87
- package/src/browser/editor-generated-preference-schema.ts +2707 -2539
- package/src/browser/editor-keybinding.ts +55 -55
- package/src/browser/editor-linenumber-contribution.ts +88 -89
- package/src/browser/editor-manager.ts +442 -442
- package/src/browser/editor-menu.ts +224 -224
- package/src/browser/editor-navigation-contribution.ts +343 -343
- package/src/browser/editor-preferences.ts +226 -226
- package/src/browser/editor-variable-contribution.ts +54 -54
- package/src/browser/editor-widget-factory.ts +82 -82
- package/src/browser/editor-widget.ts +137 -130
- package/src/browser/editor.ts +360 -358
- package/src/browser/index.ts +26 -26
- package/src/browser/language-status/editor-language-status-service.ts +271 -271
- package/src/browser/language-status/editor-language-status.css +101 -101
- package/src/browser/navigation/navigation-location-service.spec.ts +245 -245
- package/src/browser/navigation/navigation-location-service.ts +284 -284
- package/src/browser/navigation/navigation-location-similarity.spec.ts +46 -46
- package/src/browser/navigation/navigation-location-similarity.ts +58 -58
- package/src/browser/navigation/navigation-location-updater.spec.ts +197 -197
- package/src/browser/navigation/navigation-location-updater.ts +220 -220
- package/src/browser/navigation/navigation-location.ts +418 -418
- package/src/browser/navigation/test/mock-navigation-location-updater.ts +41 -41
- package/src/browser/quick-editor-service.ts +94 -94
- package/src/browser/style/index.css +19 -19
- package/src/browser/undo-redo-service.ts +120 -120
- package/src/common/language-selector.ts +104 -104
- 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
|
+
}
|