@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,427 +1,427 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2017 TypeFox and others.
4
- //
5
- // This program and the accompanying materials are made available under the
6
- // terms of the Eclipse Public License v. 2.0 which is available at
7
- // http://www.eclipse.org/legal/epl-2.0.
8
- //
9
- // This Source Code may also be made available under the following Secondary
10
- // Licenses when the conditions for such availability set forth in the Eclipse
11
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
- // with the GNU Classpath Exception which is available at
13
- // https://www.gnu.org/software/classpath/license.html.
14
- //
15
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
- // *****************************************************************************
17
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
- return c > 3 && r && Object.defineProperty(target, key, r), r;
22
- };
23
- var __metadata = (this && this.__metadata) || function (k, v) {
24
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
- };
26
- var EditorCommandContribution_1;
27
- Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.EditorCommandContribution = exports.EditorCommands = void 0;
29
- const inversify_1 = require("@theia/core/shared/inversify");
30
- const common_1 = require("@theia/core/lib/common");
31
- const uri_1 = require("@theia/core/lib/common/uri");
32
- const browser_1 = require("@theia/core/lib/browser");
33
- const editor_manager_1 = require("./editor-manager");
34
- const editor_preferences_1 = require("./editor-preferences");
35
- const core_1 = require("@theia/core");
36
- const language_service_1 = require("@theia/core/lib/browser/language-service");
37
- const supported_encodings_1 = require("@theia/core/lib/browser/supported-encodings");
38
- const nls_1 = require("@theia/core/lib/common/nls");
39
- var EditorCommands;
40
- (function (EditorCommands) {
41
- const EDITOR_CATEGORY = 'Editor';
42
- const EDITOR_CATEGORY_KEY = nls_1.nls.getDefaultKey(EDITOR_CATEGORY);
43
- EditorCommands.GOTO_LINE_COLUMN = common_1.Command.toDefaultLocalizedCommand({
44
- id: 'editor.action.gotoLine',
45
- label: 'Go to Line/Column'
46
- });
47
- /**
48
- * Show editor references
49
- */
50
- EditorCommands.SHOW_REFERENCES = {
51
- id: 'textEditor.commands.showReferences'
52
- };
53
- /**
54
- * Change indentation configuration (i.e., indent using tabs / spaces, and how many spaces per tab)
55
- */
56
- EditorCommands.CONFIG_INDENTATION = {
57
- id: 'textEditor.commands.configIndentation'
58
- };
59
- EditorCommands.CONFIG_EOL = common_1.Command.toDefaultLocalizedCommand({
60
- id: 'textEditor.commands.configEol',
61
- category: EDITOR_CATEGORY,
62
- label: 'Change End of Line Sequence'
63
- });
64
- EditorCommands.INDENT_USING_SPACES = common_1.Command.toDefaultLocalizedCommand({
65
- id: 'textEditor.commands.indentUsingSpaces',
66
- category: EDITOR_CATEGORY,
67
- label: 'Indent Using Spaces'
68
- });
69
- EditorCommands.INDENT_USING_TABS = common_1.Command.toDefaultLocalizedCommand({
70
- id: 'textEditor.commands.indentUsingTabs',
71
- category: EDITOR_CATEGORY,
72
- label: 'Indent Using Tabs'
73
- });
74
- EditorCommands.CHANGE_LANGUAGE = common_1.Command.toDefaultLocalizedCommand({
75
- id: 'textEditor.change.language',
76
- category: EDITOR_CATEGORY,
77
- label: 'Change Language Mode'
78
- });
79
- EditorCommands.CHANGE_ENCODING = common_1.Command.toDefaultLocalizedCommand({
80
- id: 'textEditor.change.encoding',
81
- category: EDITOR_CATEGORY,
82
- label: 'Change File Encoding'
83
- });
84
- EditorCommands.REVERT_EDITOR = common_1.Command.toDefaultLocalizedCommand({
85
- id: 'workbench.action.files.revert',
86
- category: browser_1.CommonCommands.FILE_CATEGORY,
87
- label: 'Revert File',
88
- });
89
- EditorCommands.REVERT_AND_CLOSE = common_1.Command.toDefaultLocalizedCommand({
90
- id: 'workbench.action.revertAndCloseActiveEditor',
91
- category: browser_1.CommonCommands.VIEW_CATEGORY,
92
- label: 'Revert and Close Editor'
93
- });
94
- /**
95
- * Command for going back to the last editor navigation location.
96
- */
97
- EditorCommands.GO_BACK = common_1.Command.toDefaultLocalizedCommand({
98
- id: 'textEditor.commands.go.back',
99
- category: EDITOR_CATEGORY,
100
- label: 'Go Back'
101
- });
102
- /**
103
- * Command for going to the forthcoming editor navigation location.
104
- */
105
- EditorCommands.GO_FORWARD = common_1.Command.toDefaultLocalizedCommand({
106
- id: 'textEditor.commands.go.forward',
107
- category: EDITOR_CATEGORY,
108
- label: 'Go Forward'
109
- });
110
- /**
111
- * Command that reveals the last text edit location, if any.
112
- */
113
- EditorCommands.GO_LAST_EDIT = common_1.Command.toDefaultLocalizedCommand({
114
- id: 'textEditor.commands.go.lastEdit',
115
- category: EDITOR_CATEGORY,
116
- label: 'Go to Last Edit Location'
117
- });
118
- /**
119
- * Command that clears the editor navigation history.
120
- */
121
- EditorCommands.CLEAR_EDITOR_HISTORY = common_1.Command.toDefaultLocalizedCommand({
122
- id: 'textEditor.commands.clear.history',
123
- category: EDITOR_CATEGORY,
124
- label: 'Clear Editor History'
125
- });
126
- /**
127
- * Command that displays all editors that are currently opened.
128
- */
129
- EditorCommands.SHOW_ALL_OPENED_EDITORS = common_1.Command.toLocalizedCommand({
130
- id: 'workbench.action.showAllEditors',
131
- category: browser_1.CommonCommands.VIEW_CATEGORY,
132
- label: 'Show All Opened Editors'
133
- }, 'theia/editor/showAllEditors', EDITOR_CATEGORY_KEY);
134
- /**
135
- * Command that toggles the minimap.
136
- */
137
- EditorCommands.TOGGLE_MINIMAP = common_1.Command.toDefaultLocalizedCommand({
138
- id: 'editor.action.toggleMinimap',
139
- category: browser_1.CommonCommands.VIEW_CATEGORY,
140
- label: 'Toggle Minimap'
141
- });
142
- /**
143
- * Command that toggles the rendering of whitespace characters in the editor.
144
- */
145
- EditorCommands.TOGGLE_RENDER_WHITESPACE = common_1.Command.toDefaultLocalizedCommand({
146
- id: 'editor.action.toggleRenderWhitespace',
147
- category: browser_1.CommonCommands.VIEW_CATEGORY,
148
- label: 'Toggle Render Whitespace'
149
- });
150
- /**
151
- * Command that toggles the word wrap.
152
- */
153
- EditorCommands.TOGGLE_WORD_WRAP = common_1.Command.toDefaultLocalizedCommand({
154
- id: 'editor.action.toggleWordWrap',
155
- label: 'View: Toggle Word Wrap'
156
- });
157
- /**
158
- * Command that toggles sticky scroll.
159
- */
160
- EditorCommands.TOGGLE_STICKY_SCROLL = common_1.Command.toLocalizedCommand({
161
- id: 'editor.action.toggleStickyScroll',
162
- category: browser_1.CommonCommands.VIEW_CATEGORY,
163
- label: 'Toggle Sticky Scroll',
164
- }, 'theia/editor/toggleStickyScroll', EDITOR_CATEGORY_KEY);
165
- /**
166
- * Command that re-opens the last closed editor.
167
- */
168
- EditorCommands.REOPEN_CLOSED_EDITOR = common_1.Command.toDefaultLocalizedCommand({
169
- id: 'workbench.action.reopenClosedEditor',
170
- category: browser_1.CommonCommands.VIEW_CATEGORY,
171
- label: 'Reopen Closed Editor'
172
- });
173
- /**
174
- * Opens a second instance of the current editor, splitting the view in the direction specified.
175
- */
176
- EditorCommands.SPLIT_EDITOR_RIGHT = common_1.Command.toDefaultLocalizedCommand({
177
- id: 'workbench.action.splitEditorRight',
178
- category: browser_1.CommonCommands.VIEW_CATEGORY,
179
- label: 'Split Editor Right'
180
- });
181
- EditorCommands.SPLIT_EDITOR_DOWN = common_1.Command.toDefaultLocalizedCommand({
182
- id: 'workbench.action.splitEditorDown',
183
- category: browser_1.CommonCommands.VIEW_CATEGORY,
184
- label: 'Split Editor Down'
185
- });
186
- EditorCommands.SPLIT_EDITOR_UP = common_1.Command.toDefaultLocalizedCommand({
187
- id: 'workbench.action.splitEditorUp',
188
- category: browser_1.CommonCommands.VIEW_CATEGORY,
189
- label: 'Split Editor Up'
190
- });
191
- EditorCommands.SPLIT_EDITOR_LEFT = common_1.Command.toDefaultLocalizedCommand({
192
- id: 'workbench.action.splitEditorLeft',
193
- category: browser_1.CommonCommands.VIEW_CATEGORY,
194
- label: 'Split Editor Left'
195
- });
196
- /**
197
- * Default horizontal split: right.
198
- */
199
- EditorCommands.SPLIT_EDITOR_HORIZONTAL = common_1.Command.toDefaultLocalizedCommand({
200
- id: 'workbench.action.splitEditor',
201
- category: browser_1.CommonCommands.VIEW_CATEGORY,
202
- label: 'Split Editor'
203
- });
204
- /**
205
- * Default vertical split: down.
206
- */
207
- EditorCommands.SPLIT_EDITOR_VERTICAL = common_1.Command.toDefaultLocalizedCommand({
208
- id: 'workbench.action.splitEditorOrthogonal',
209
- category: browser_1.CommonCommands.VIEW_CATEGORY,
210
- label: 'Split Editor Orthogonal'
211
- });
212
- })(EditorCommands = exports.EditorCommands || (exports.EditorCommands = {}));
213
- let EditorCommandContribution = EditorCommandContribution_1 = class EditorCommandContribution {
214
- init() {
215
- this.editorPreferences.onPreferenceChanged(e => {
216
- if (e.preferenceName === 'files.autoSave' && e.newValue !== 'off') {
217
- this.shell.saveAll();
218
- }
219
- });
220
- }
221
- registerCommands(registry) {
222
- registry.registerCommand(EditorCommands.SHOW_REFERENCES);
223
- registry.registerCommand(EditorCommands.CONFIG_INDENTATION);
224
- registry.registerCommand(EditorCommands.CONFIG_EOL);
225
- registry.registerCommand(EditorCommands.INDENT_USING_SPACES);
226
- registry.registerCommand(EditorCommands.INDENT_USING_TABS);
227
- registry.registerCommand(EditorCommands.REVERT_EDITOR);
228
- registry.registerCommand(EditorCommands.REVERT_AND_CLOSE);
229
- registry.registerCommand(EditorCommands.CHANGE_LANGUAGE, {
230
- isEnabled: () => this.canConfigureLanguage(),
231
- isVisible: () => this.canConfigureLanguage(),
232
- execute: () => this.configureLanguage()
233
- });
234
- registry.registerCommand(EditorCommands.CHANGE_ENCODING, {
235
- isEnabled: () => this.canConfigureEncoding(),
236
- isVisible: () => this.canConfigureEncoding(),
237
- execute: () => this.configureEncoding()
238
- });
239
- registry.registerCommand(EditorCommands.GO_BACK);
240
- registry.registerCommand(EditorCommands.GO_FORWARD);
241
- registry.registerCommand(EditorCommands.GO_LAST_EDIT);
242
- registry.registerCommand(EditorCommands.CLEAR_EDITOR_HISTORY);
243
- registry.registerCommand(EditorCommands.TOGGLE_MINIMAP);
244
- registry.registerCommand(EditorCommands.TOGGLE_RENDER_WHITESPACE);
245
- registry.registerCommand(EditorCommands.TOGGLE_WORD_WRAP);
246
- registry.registerCommand(EditorCommands.TOGGLE_STICKY_SCROLL);
247
- registry.registerCommand(EditorCommands.REOPEN_CLOSED_EDITOR);
248
- registry.registerCommand(browser_1.CommonCommands.AUTO_SAVE, {
249
- isToggled: () => this.isAutoSaveOn(),
250
- execute: () => this.toggleAutoSave()
251
- });
252
- }
253
- canConfigureLanguage() {
254
- const widget = this.editorManager.currentEditor;
255
- const editor = widget && widget.editor;
256
- return !!editor && !!this.languages.languages;
257
- }
258
- async configureLanguage() {
259
- var _a;
260
- const widget = this.editorManager.currentEditor;
261
- const editor = widget && widget.editor;
262
- if (!editor || !this.languages.languages) {
263
- return;
264
- }
265
- const current = editor.document.languageId;
266
- const items = [
267
- { label: nls_1.nls.localizeByDefault('Auto Detect'), value: 'autoDetect' },
268
- { type: 'separator', label: nls_1.nls.localizeByDefault('languages (identifier)') },
269
- ...(this.languages.languages.map(language => this.toQuickPickLanguage(language, current))).sort((e, e2) => e.label.localeCompare(e2.label))
270
- ];
271
- const selectedMode = await ((_a = this.quickInputService) === null || _a === void 0 ? void 0 : _a.showQuickPick(items, { placeholder: nls_1.nls.localizeByDefault('Select Language Mode') }));
272
- if (selectedMode && ('value' in selectedMode)) {
273
- if (selectedMode.value === 'autoDetect') {
274
- editor.detectLanguage();
275
- }
276
- else if (selectedMode.value) {
277
- editor.setLanguage(selectedMode.value.id);
278
- }
279
- }
280
- }
281
- canConfigureEncoding() {
282
- const widget = this.editorManager.currentEditor;
283
- const editor = widget && widget.editor;
284
- return !!editor;
285
- }
286
- async configureEncoding() {
287
- var _a, _b;
288
- const widget = this.editorManager.currentEditor;
289
- const editor = widget && widget.editor;
290
- if (!editor) {
291
- return;
292
- }
293
- const reopenWithEncodingPick = { label: nls_1.nls.localizeByDefault('Reopen with Encoding'), value: 'reopen' };
294
- const saveWithEncodingPick = { label: nls_1.nls.localizeByDefault('Save with Encoding'), value: 'save' };
295
- const actionItems = [
296
- reopenWithEncodingPick,
297
- saveWithEncodingPick
298
- ];
299
- const selectedEncoding = await ((_a = this.quickInputService) === null || _a === void 0 ? void 0 : _a.showQuickPick(actionItems, { placeholder: nls_1.nls.localizeByDefault('Select Action') }));
300
- if (!selectedEncoding) {
301
- return;
302
- }
303
- const isReopenWithEncoding = (selectedEncoding.value === reopenWithEncodingPick.value);
304
- const configuredEncoding = this.preferencesService.get('files.encoding', 'utf8', editor.uri.toString());
305
- const resource = await this.resourceProvider(editor.uri);
306
- const guessedEncoding = resource.guessEncoding ? await resource.guessEncoding() : undefined;
307
- resource.dispose();
308
- const encodingItems = Object.keys(supported_encodings_1.SUPPORTED_ENCODINGS)
309
- .sort((k1, k2) => {
310
- if (k1 === configuredEncoding) {
311
- return -1;
312
- }
313
- else if (k2 === configuredEncoding) {
314
- return 1;
315
- }
316
- return supported_encodings_1.SUPPORTED_ENCODINGS[k1].order - supported_encodings_1.SUPPORTED_ENCODINGS[k2].order;
317
- })
318
- .filter(k => {
319
- if (k === guessedEncoding && guessedEncoding !== configuredEncoding) {
320
- return false; // do not show encoding if it is the guessed encoding that does not match the configured
321
- }
322
- return !isReopenWithEncoding || !supported_encodings_1.SUPPORTED_ENCODINGS[k].encodeOnly; // hide those that can only be used for encoding if we are about to decode
323
- })
324
- .map(key => ({ label: supported_encodings_1.SUPPORTED_ENCODINGS[key].labelLong, value: { id: key, description: key } }));
325
- // Insert guessed encoding
326
- if (guessedEncoding && configuredEncoding !== guessedEncoding && supported_encodings_1.SUPPORTED_ENCODINGS[guessedEncoding]) {
327
- encodingItems.unshift({
328
- label: `${nls_1.nls.localizeByDefault('Guessed from content')}: ${supported_encodings_1.SUPPORTED_ENCODINGS[guessedEncoding].labelLong}`,
329
- value: { id: guessedEncoding, description: guessedEncoding }
330
- });
331
- }
332
- const selectedFileEncoding = await ((_b = this.quickInputService) === null || _b === void 0 ? void 0 : _b.showQuickPick(encodingItems, {
333
- placeholder: isReopenWithEncoding ?
334
- nls_1.nls.localizeByDefault('Select File Encoding to Reopen File') :
335
- nls_1.nls.localizeByDefault('Select File Encoding to Save with')
336
- }));
337
- if (!selectedFileEncoding) {
338
- return;
339
- }
340
- if (editor.document.dirty && isReopenWithEncoding) {
341
- this.messageService.info(nls_1.nls.localize('theia/editor/dirtyEncoding', 'The file is dirty. Please save it first before reopening it with another encoding.'));
342
- return;
343
- }
344
- else if (selectedFileEncoding.value) {
345
- editor.setEncoding(selectedFileEncoding.value.id, isReopenWithEncoding ? 1 /* Decode */ : 0 /* Encode */);
346
- }
347
- }
348
- toQuickPickLanguage(value, current) {
349
- const languageUri = this.toLanguageUri(value);
350
- const icon = this.labelProvider.getIcon(languageUri);
351
- const iconClasses = icon !== '' ? [icon + ' file-icon'] : undefined;
352
- const configured = current === value.id;
353
- return {
354
- value,
355
- label: value.name,
356
- description: nls_1.nls.localizeByDefault(`({0})${configured ? ' - Configured Language' : ''}`, value.id),
357
- iconClasses
358
- };
359
- }
360
- toLanguageUri(language) {
361
- const extension = language.extensions.values().next();
362
- if (extension.value) {
363
- return new uri_1.default('file:///' + extension.value);
364
- }
365
- const filename = language.filenames.values().next();
366
- if (filename.value) {
367
- return new uri_1.default('file:///' + filename.value);
368
- }
369
- return new uri_1.default('file:///.txt');
370
- }
371
- isAutoSaveOn() {
372
- const autoSave = this.preferencesService.get(EditorCommandContribution_1.AUTOSAVE_PREFERENCE);
373
- return autoSave !== 'off';
374
- }
375
- async toggleAutoSave() {
376
- this.preferencesService.updateValue(EditorCommandContribution_1.AUTOSAVE_PREFERENCE, this.isAutoSaveOn() ? 'off' : 'afterDelay');
377
- }
378
- };
379
- EditorCommandContribution.AUTOSAVE_PREFERENCE = 'files.autoSave';
380
- __decorate([
381
- (0, inversify_1.inject)(browser_1.ApplicationShell),
382
- __metadata("design:type", browser_1.ApplicationShell)
383
- ], EditorCommandContribution.prototype, "shell", void 0);
384
- __decorate([
385
- (0, inversify_1.inject)(browser_1.PreferenceService),
386
- __metadata("design:type", Object)
387
- ], EditorCommandContribution.prototype, "preferencesService", void 0);
388
- __decorate([
389
- (0, inversify_1.inject)(editor_preferences_1.EditorPreferences),
390
- __metadata("design:type", Object)
391
- ], EditorCommandContribution.prototype, "editorPreferences", void 0);
392
- __decorate([
393
- (0, inversify_1.inject)(browser_1.QuickInputService),
394
- (0, inversify_1.optional)(),
395
- __metadata("design:type", Object)
396
- ], EditorCommandContribution.prototype, "quickInputService", void 0);
397
- __decorate([
398
- (0, inversify_1.inject)(core_1.MessageService),
399
- __metadata("design:type", core_1.MessageService)
400
- ], EditorCommandContribution.prototype, "messageService", void 0);
401
- __decorate([
402
- (0, inversify_1.inject)(browser_1.LabelProvider),
403
- __metadata("design:type", browser_1.LabelProvider)
404
- ], EditorCommandContribution.prototype, "labelProvider", void 0);
405
- __decorate([
406
- (0, inversify_1.inject)(language_service_1.LanguageService),
407
- __metadata("design:type", language_service_1.LanguageService)
408
- ], EditorCommandContribution.prototype, "languages", void 0);
409
- __decorate([
410
- (0, inversify_1.inject)(editor_manager_1.EditorManager),
411
- __metadata("design:type", editor_manager_1.EditorManager)
412
- ], EditorCommandContribution.prototype, "editorManager", void 0);
413
- __decorate([
414
- (0, inversify_1.inject)(core_1.ResourceProvider),
415
- __metadata("design:type", Function)
416
- ], EditorCommandContribution.prototype, "resourceProvider", void 0);
417
- __decorate([
418
- (0, inversify_1.postConstruct)(),
419
- __metadata("design:type", Function),
420
- __metadata("design:paramtypes", []),
421
- __metadata("design:returntype", void 0)
422
- ], EditorCommandContribution.prototype, "init", null);
423
- EditorCommandContribution = EditorCommandContribution_1 = __decorate([
424
- (0, inversify_1.injectable)()
425
- ], EditorCommandContribution);
426
- exports.EditorCommandContribution = EditorCommandContribution;
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2017 TypeFox and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
23
+ var __metadata = (this && this.__metadata) || function (k, v) {
24
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
+ };
26
+ var EditorCommandContribution_1;
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.EditorCommandContribution = exports.EditorCommands = void 0;
29
+ const inversify_1 = require("@theia/core/shared/inversify");
30
+ const common_1 = require("@theia/core/lib/common");
31
+ const uri_1 = require("@theia/core/lib/common/uri");
32
+ const browser_1 = require("@theia/core/lib/browser");
33
+ const editor_manager_1 = require("./editor-manager");
34
+ const editor_preferences_1 = require("./editor-preferences");
35
+ const core_1 = require("@theia/core");
36
+ const language_service_1 = require("@theia/core/lib/browser/language-service");
37
+ const supported_encodings_1 = require("@theia/core/lib/browser/supported-encodings");
38
+ const nls_1 = require("@theia/core/lib/common/nls");
39
+ var EditorCommands;
40
+ (function (EditorCommands) {
41
+ const EDITOR_CATEGORY = 'Editor';
42
+ const EDITOR_CATEGORY_KEY = nls_1.nls.getDefaultKey(EDITOR_CATEGORY);
43
+ EditorCommands.GOTO_LINE_COLUMN = common_1.Command.toDefaultLocalizedCommand({
44
+ id: 'editor.action.gotoLine',
45
+ label: 'Go to Line/Column'
46
+ });
47
+ /**
48
+ * Show editor references
49
+ */
50
+ EditorCommands.SHOW_REFERENCES = {
51
+ id: 'textEditor.commands.showReferences'
52
+ };
53
+ /**
54
+ * Change indentation configuration (i.e., indent using tabs / spaces, and how many spaces per tab)
55
+ */
56
+ EditorCommands.CONFIG_INDENTATION = {
57
+ id: 'textEditor.commands.configIndentation'
58
+ };
59
+ EditorCommands.CONFIG_EOL = common_1.Command.toDefaultLocalizedCommand({
60
+ id: 'textEditor.commands.configEol',
61
+ category: EDITOR_CATEGORY,
62
+ label: 'Change End of Line Sequence'
63
+ });
64
+ EditorCommands.INDENT_USING_SPACES = common_1.Command.toDefaultLocalizedCommand({
65
+ id: 'textEditor.commands.indentUsingSpaces',
66
+ category: EDITOR_CATEGORY,
67
+ label: 'Indent Using Spaces'
68
+ });
69
+ EditorCommands.INDENT_USING_TABS = common_1.Command.toDefaultLocalizedCommand({
70
+ id: 'textEditor.commands.indentUsingTabs',
71
+ category: EDITOR_CATEGORY,
72
+ label: 'Indent Using Tabs'
73
+ });
74
+ EditorCommands.CHANGE_LANGUAGE = common_1.Command.toDefaultLocalizedCommand({
75
+ id: 'textEditor.change.language',
76
+ category: EDITOR_CATEGORY,
77
+ label: 'Change Language Mode'
78
+ });
79
+ EditorCommands.CHANGE_ENCODING = common_1.Command.toDefaultLocalizedCommand({
80
+ id: 'textEditor.change.encoding',
81
+ category: EDITOR_CATEGORY,
82
+ label: 'Change File Encoding'
83
+ });
84
+ EditorCommands.REVERT_EDITOR = common_1.Command.toDefaultLocalizedCommand({
85
+ id: 'workbench.action.files.revert',
86
+ category: browser_1.CommonCommands.FILE_CATEGORY,
87
+ label: 'Revert File',
88
+ });
89
+ EditorCommands.REVERT_AND_CLOSE = common_1.Command.toDefaultLocalizedCommand({
90
+ id: 'workbench.action.revertAndCloseActiveEditor',
91
+ category: browser_1.CommonCommands.VIEW_CATEGORY,
92
+ label: 'Revert and Close Editor'
93
+ });
94
+ /**
95
+ * Command for going back to the last editor navigation location.
96
+ */
97
+ EditorCommands.GO_BACK = common_1.Command.toDefaultLocalizedCommand({
98
+ id: 'textEditor.commands.go.back',
99
+ category: EDITOR_CATEGORY,
100
+ label: 'Go Back'
101
+ });
102
+ /**
103
+ * Command for going to the forthcoming editor navigation location.
104
+ */
105
+ EditorCommands.GO_FORWARD = common_1.Command.toDefaultLocalizedCommand({
106
+ id: 'textEditor.commands.go.forward',
107
+ category: EDITOR_CATEGORY,
108
+ label: 'Go Forward'
109
+ });
110
+ /**
111
+ * Command that reveals the last text edit location, if any.
112
+ */
113
+ EditorCommands.GO_LAST_EDIT = common_1.Command.toDefaultLocalizedCommand({
114
+ id: 'textEditor.commands.go.lastEdit',
115
+ category: EDITOR_CATEGORY,
116
+ label: 'Go to Last Edit Location'
117
+ });
118
+ /**
119
+ * Command that clears the editor navigation history.
120
+ */
121
+ EditorCommands.CLEAR_EDITOR_HISTORY = common_1.Command.toDefaultLocalizedCommand({
122
+ id: 'textEditor.commands.clear.history',
123
+ category: EDITOR_CATEGORY,
124
+ label: 'Clear Editor History'
125
+ });
126
+ /**
127
+ * Command that displays all editors that are currently opened.
128
+ */
129
+ EditorCommands.SHOW_ALL_OPENED_EDITORS = common_1.Command.toLocalizedCommand({
130
+ id: 'workbench.action.showAllEditors',
131
+ category: browser_1.CommonCommands.VIEW_CATEGORY,
132
+ label: 'Show All Opened Editors'
133
+ }, 'theia/editor/showAllEditors', EDITOR_CATEGORY_KEY);
134
+ /**
135
+ * Command that toggles the minimap.
136
+ */
137
+ EditorCommands.TOGGLE_MINIMAP = common_1.Command.toDefaultLocalizedCommand({
138
+ id: 'editor.action.toggleMinimap',
139
+ category: browser_1.CommonCommands.VIEW_CATEGORY,
140
+ label: 'Toggle Minimap'
141
+ });
142
+ /**
143
+ * Command that toggles the rendering of whitespace characters in the editor.
144
+ */
145
+ EditorCommands.TOGGLE_RENDER_WHITESPACE = common_1.Command.toDefaultLocalizedCommand({
146
+ id: 'editor.action.toggleRenderWhitespace',
147
+ category: browser_1.CommonCommands.VIEW_CATEGORY,
148
+ label: 'Toggle Render Whitespace'
149
+ });
150
+ /**
151
+ * Command that toggles the word wrap.
152
+ */
153
+ EditorCommands.TOGGLE_WORD_WRAP = common_1.Command.toDefaultLocalizedCommand({
154
+ id: 'editor.action.toggleWordWrap',
155
+ label: 'View: Toggle Word Wrap'
156
+ });
157
+ /**
158
+ * Command that toggles sticky scroll.
159
+ */
160
+ EditorCommands.TOGGLE_STICKY_SCROLL = common_1.Command.toLocalizedCommand({
161
+ id: 'editor.action.toggleStickyScroll',
162
+ category: browser_1.CommonCommands.VIEW_CATEGORY,
163
+ label: 'Toggle Sticky Scroll',
164
+ }, 'theia/editor/toggleStickyScroll', EDITOR_CATEGORY_KEY);
165
+ /**
166
+ * Command that re-opens the last closed editor.
167
+ */
168
+ EditorCommands.REOPEN_CLOSED_EDITOR = common_1.Command.toDefaultLocalizedCommand({
169
+ id: 'workbench.action.reopenClosedEditor',
170
+ category: browser_1.CommonCommands.VIEW_CATEGORY,
171
+ label: 'Reopen Closed Editor'
172
+ });
173
+ /**
174
+ * Opens a second instance of the current editor, splitting the view in the direction specified.
175
+ */
176
+ EditorCommands.SPLIT_EDITOR_RIGHT = common_1.Command.toDefaultLocalizedCommand({
177
+ id: 'workbench.action.splitEditorRight',
178
+ category: browser_1.CommonCommands.VIEW_CATEGORY,
179
+ label: 'Split Editor Right'
180
+ });
181
+ EditorCommands.SPLIT_EDITOR_DOWN = common_1.Command.toDefaultLocalizedCommand({
182
+ id: 'workbench.action.splitEditorDown',
183
+ category: browser_1.CommonCommands.VIEW_CATEGORY,
184
+ label: 'Split Editor Down'
185
+ });
186
+ EditorCommands.SPLIT_EDITOR_UP = common_1.Command.toDefaultLocalizedCommand({
187
+ id: 'workbench.action.splitEditorUp',
188
+ category: browser_1.CommonCommands.VIEW_CATEGORY,
189
+ label: 'Split Editor Up'
190
+ });
191
+ EditorCommands.SPLIT_EDITOR_LEFT = common_1.Command.toDefaultLocalizedCommand({
192
+ id: 'workbench.action.splitEditorLeft',
193
+ category: browser_1.CommonCommands.VIEW_CATEGORY,
194
+ label: 'Split Editor Left'
195
+ });
196
+ /**
197
+ * Default horizontal split: right.
198
+ */
199
+ EditorCommands.SPLIT_EDITOR_HORIZONTAL = common_1.Command.toDefaultLocalizedCommand({
200
+ id: 'workbench.action.splitEditor',
201
+ category: browser_1.CommonCommands.VIEW_CATEGORY,
202
+ label: 'Split Editor'
203
+ });
204
+ /**
205
+ * Default vertical split: down.
206
+ */
207
+ EditorCommands.SPLIT_EDITOR_VERTICAL = common_1.Command.toDefaultLocalizedCommand({
208
+ id: 'workbench.action.splitEditorOrthogonal',
209
+ category: browser_1.CommonCommands.VIEW_CATEGORY,
210
+ label: 'Split Editor Orthogonal'
211
+ });
212
+ })(EditorCommands = exports.EditorCommands || (exports.EditorCommands = {}));
213
+ let EditorCommandContribution = EditorCommandContribution_1 = class EditorCommandContribution {
214
+ init() {
215
+ this.editorPreferences.onPreferenceChanged(e => {
216
+ if (e.preferenceName === 'files.autoSave' && e.newValue !== 'off') {
217
+ this.shell.saveAll();
218
+ }
219
+ });
220
+ }
221
+ registerCommands(registry) {
222
+ registry.registerCommand(EditorCommands.SHOW_REFERENCES);
223
+ registry.registerCommand(EditorCommands.CONFIG_INDENTATION);
224
+ registry.registerCommand(EditorCommands.CONFIG_EOL);
225
+ registry.registerCommand(EditorCommands.INDENT_USING_SPACES);
226
+ registry.registerCommand(EditorCommands.INDENT_USING_TABS);
227
+ registry.registerCommand(EditorCommands.REVERT_EDITOR);
228
+ registry.registerCommand(EditorCommands.REVERT_AND_CLOSE);
229
+ registry.registerCommand(EditorCommands.CHANGE_LANGUAGE, {
230
+ isEnabled: () => this.canConfigureLanguage(),
231
+ isVisible: () => this.canConfigureLanguage(),
232
+ execute: () => this.configureLanguage()
233
+ });
234
+ registry.registerCommand(EditorCommands.CHANGE_ENCODING, {
235
+ isEnabled: () => this.canConfigureEncoding(),
236
+ isVisible: () => this.canConfigureEncoding(),
237
+ execute: () => this.configureEncoding()
238
+ });
239
+ registry.registerCommand(EditorCommands.GO_BACK);
240
+ registry.registerCommand(EditorCommands.GO_FORWARD);
241
+ registry.registerCommand(EditorCommands.GO_LAST_EDIT);
242
+ registry.registerCommand(EditorCommands.CLEAR_EDITOR_HISTORY);
243
+ registry.registerCommand(EditorCommands.TOGGLE_MINIMAP);
244
+ registry.registerCommand(EditorCommands.TOGGLE_RENDER_WHITESPACE);
245
+ registry.registerCommand(EditorCommands.TOGGLE_WORD_WRAP);
246
+ registry.registerCommand(EditorCommands.TOGGLE_STICKY_SCROLL);
247
+ registry.registerCommand(EditorCommands.REOPEN_CLOSED_EDITOR);
248
+ registry.registerCommand(browser_1.CommonCommands.AUTO_SAVE, {
249
+ isToggled: () => this.isAutoSaveOn(),
250
+ execute: () => this.toggleAutoSave()
251
+ });
252
+ }
253
+ canConfigureLanguage() {
254
+ const widget = this.editorManager.currentEditor;
255
+ const editor = widget && widget.editor;
256
+ return !!editor && !!this.languages.languages;
257
+ }
258
+ async configureLanguage() {
259
+ var _a;
260
+ const widget = this.editorManager.currentEditor;
261
+ const editor = widget && widget.editor;
262
+ if (!editor || !this.languages.languages) {
263
+ return;
264
+ }
265
+ const current = editor.document.languageId;
266
+ const items = [
267
+ { label: nls_1.nls.localizeByDefault('Auto Detect'), value: 'autoDetect' },
268
+ { type: 'separator', label: nls_1.nls.localizeByDefault('languages (identifier)') },
269
+ ...(this.languages.languages.map(language => this.toQuickPickLanguage(language, current))).sort((e, e2) => e.label.localeCompare(e2.label))
270
+ ];
271
+ const selectedMode = await ((_a = this.quickInputService) === null || _a === void 0 ? void 0 : _a.showQuickPick(items, { placeholder: nls_1.nls.localizeByDefault('Select Language Mode') }));
272
+ if (selectedMode && ('value' in selectedMode)) {
273
+ if (selectedMode.value === 'autoDetect') {
274
+ editor.detectLanguage();
275
+ }
276
+ else if (selectedMode.value) {
277
+ editor.setLanguage(selectedMode.value.id);
278
+ }
279
+ }
280
+ }
281
+ canConfigureEncoding() {
282
+ const widget = this.editorManager.currentEditor;
283
+ const editor = widget && widget.editor;
284
+ return !!editor;
285
+ }
286
+ async configureEncoding() {
287
+ var _a, _b;
288
+ const widget = this.editorManager.currentEditor;
289
+ const editor = widget && widget.editor;
290
+ if (!editor) {
291
+ return;
292
+ }
293
+ const reopenWithEncodingPick = { label: nls_1.nls.localizeByDefault('Reopen with Encoding'), value: 'reopen' };
294
+ const saveWithEncodingPick = { label: nls_1.nls.localizeByDefault('Save with Encoding'), value: 'save' };
295
+ const actionItems = [
296
+ reopenWithEncodingPick,
297
+ saveWithEncodingPick
298
+ ];
299
+ const selectedEncoding = await ((_a = this.quickInputService) === null || _a === void 0 ? void 0 : _a.showQuickPick(actionItems, { placeholder: nls_1.nls.localizeByDefault('Select Action') }));
300
+ if (!selectedEncoding) {
301
+ return;
302
+ }
303
+ const isReopenWithEncoding = (selectedEncoding.value === reopenWithEncodingPick.value);
304
+ const configuredEncoding = this.preferencesService.get('files.encoding', 'utf8', editor.uri.toString());
305
+ const resource = await this.resourceProvider(editor.uri);
306
+ const guessedEncoding = resource.guessEncoding ? await resource.guessEncoding() : undefined;
307
+ resource.dispose();
308
+ const encodingItems = Object.keys(supported_encodings_1.SUPPORTED_ENCODINGS)
309
+ .sort((k1, k2) => {
310
+ if (k1 === configuredEncoding) {
311
+ return -1;
312
+ }
313
+ else if (k2 === configuredEncoding) {
314
+ return 1;
315
+ }
316
+ return supported_encodings_1.SUPPORTED_ENCODINGS[k1].order - supported_encodings_1.SUPPORTED_ENCODINGS[k2].order;
317
+ })
318
+ .filter(k => {
319
+ if (k === guessedEncoding && guessedEncoding !== configuredEncoding) {
320
+ return false; // do not show encoding if it is the guessed encoding that does not match the configured
321
+ }
322
+ return !isReopenWithEncoding || !supported_encodings_1.SUPPORTED_ENCODINGS[k].encodeOnly; // hide those that can only be used for encoding if we are about to decode
323
+ })
324
+ .map(key => ({ label: supported_encodings_1.SUPPORTED_ENCODINGS[key].labelLong, value: { id: key, description: key } }));
325
+ // Insert guessed encoding
326
+ if (guessedEncoding && configuredEncoding !== guessedEncoding && supported_encodings_1.SUPPORTED_ENCODINGS[guessedEncoding]) {
327
+ encodingItems.unshift({
328
+ label: `${nls_1.nls.localizeByDefault('Guessed from content')}: ${supported_encodings_1.SUPPORTED_ENCODINGS[guessedEncoding].labelLong}`,
329
+ value: { id: guessedEncoding, description: guessedEncoding }
330
+ });
331
+ }
332
+ const selectedFileEncoding = await ((_b = this.quickInputService) === null || _b === void 0 ? void 0 : _b.showQuickPick(encodingItems, {
333
+ placeholder: isReopenWithEncoding ?
334
+ nls_1.nls.localizeByDefault('Select File Encoding to Reopen File') :
335
+ nls_1.nls.localizeByDefault('Select File Encoding to Save with')
336
+ }));
337
+ if (!selectedFileEncoding) {
338
+ return;
339
+ }
340
+ if (editor.document.dirty && isReopenWithEncoding) {
341
+ this.messageService.info(nls_1.nls.localize('theia/editor/dirtyEncoding', 'The file is dirty. Please save it first before reopening it with another encoding.'));
342
+ return;
343
+ }
344
+ else if (selectedFileEncoding.value) {
345
+ editor.setEncoding(selectedFileEncoding.value.id, isReopenWithEncoding ? 1 /* Decode */ : 0 /* Encode */);
346
+ }
347
+ }
348
+ toQuickPickLanguage(value, current) {
349
+ const languageUri = this.toLanguageUri(value);
350
+ const icon = this.labelProvider.getIcon(languageUri);
351
+ const iconClasses = icon !== '' ? [icon + ' file-icon'] : undefined;
352
+ const configured = current === value.id;
353
+ return {
354
+ value,
355
+ label: value.name,
356
+ description: nls_1.nls.localizeByDefault(`({0})${configured ? ' - Configured Language' : ''}`, value.id),
357
+ iconClasses
358
+ };
359
+ }
360
+ toLanguageUri(language) {
361
+ const extension = language.extensions.values().next();
362
+ if (extension.value) {
363
+ return new uri_1.default('file:///' + extension.value);
364
+ }
365
+ const filename = language.filenames.values().next();
366
+ if (filename.value) {
367
+ return new uri_1.default('file:///' + filename.value);
368
+ }
369
+ return new uri_1.default('file:///.txt');
370
+ }
371
+ isAutoSaveOn() {
372
+ const autoSave = this.preferencesService.get(EditorCommandContribution_1.AUTOSAVE_PREFERENCE);
373
+ return autoSave !== 'off';
374
+ }
375
+ async toggleAutoSave() {
376
+ this.preferencesService.updateValue(EditorCommandContribution_1.AUTOSAVE_PREFERENCE, this.isAutoSaveOn() ? 'off' : 'afterDelay');
377
+ }
378
+ };
379
+ EditorCommandContribution.AUTOSAVE_PREFERENCE = 'files.autoSave';
380
+ __decorate([
381
+ (0, inversify_1.inject)(browser_1.ApplicationShell),
382
+ __metadata("design:type", browser_1.ApplicationShell)
383
+ ], EditorCommandContribution.prototype, "shell", void 0);
384
+ __decorate([
385
+ (0, inversify_1.inject)(browser_1.PreferenceService),
386
+ __metadata("design:type", Object)
387
+ ], EditorCommandContribution.prototype, "preferencesService", void 0);
388
+ __decorate([
389
+ (0, inversify_1.inject)(editor_preferences_1.EditorPreferences),
390
+ __metadata("design:type", Object)
391
+ ], EditorCommandContribution.prototype, "editorPreferences", void 0);
392
+ __decorate([
393
+ (0, inversify_1.inject)(browser_1.QuickInputService),
394
+ (0, inversify_1.optional)(),
395
+ __metadata("design:type", Object)
396
+ ], EditorCommandContribution.prototype, "quickInputService", void 0);
397
+ __decorate([
398
+ (0, inversify_1.inject)(core_1.MessageService),
399
+ __metadata("design:type", core_1.MessageService)
400
+ ], EditorCommandContribution.prototype, "messageService", void 0);
401
+ __decorate([
402
+ (0, inversify_1.inject)(browser_1.LabelProvider),
403
+ __metadata("design:type", browser_1.LabelProvider)
404
+ ], EditorCommandContribution.prototype, "labelProvider", void 0);
405
+ __decorate([
406
+ (0, inversify_1.inject)(language_service_1.LanguageService),
407
+ __metadata("design:type", language_service_1.LanguageService)
408
+ ], EditorCommandContribution.prototype, "languages", void 0);
409
+ __decorate([
410
+ (0, inversify_1.inject)(editor_manager_1.EditorManager),
411
+ __metadata("design:type", editor_manager_1.EditorManager)
412
+ ], EditorCommandContribution.prototype, "editorManager", void 0);
413
+ __decorate([
414
+ (0, inversify_1.inject)(core_1.ResourceProvider),
415
+ __metadata("design:type", Function)
416
+ ], EditorCommandContribution.prototype, "resourceProvider", void 0);
417
+ __decorate([
418
+ (0, inversify_1.postConstruct)(),
419
+ __metadata("design:type", Function),
420
+ __metadata("design:paramtypes", []),
421
+ __metadata("design:returntype", void 0)
422
+ ], EditorCommandContribution.prototype, "init", null);
423
+ EditorCommandContribution = EditorCommandContribution_1 = __decorate([
424
+ (0, inversify_1.injectable)()
425
+ ], EditorCommandContribution);
426
+ exports.EditorCommandContribution = EditorCommandContribution;
427
427
  //# sourceMappingURL=editor-command.js.map