@codingame/monaco-vscode-api 1.83.15-next.0 → 1.83.16

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 (53) hide show
  1. package/README.md +430 -0
  2. package/contributions.js +3 -0
  3. package/localExtensionHost.js +3 -2
  4. package/missing-services.js +57 -1
  5. package/monaco-editor-treemending.patch +3375 -3375
  6. package/package.json +6 -6
  7. package/vscode/src/vs/base/common/prefixTree.js +130 -0
  8. package/vscode/src/vs/platform/actions/browser/floatingMenu.js +26 -2
  9. package/vscode/src/vs/platform/terminal/common/capabilities/bufferMarkCapability.js +41 -0
  10. package/vscode/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.js +566 -0
  11. package/vscode/src/vs/platform/terminal/common/capabilities/cwdDetectionCapability.js +29 -0
  12. package/vscode/src/vs/platform/terminal/common/capabilities/partialCommandDetectionCapability.js +48 -0
  13. package/vscode/src/vs/platform/terminal/common/capabilities/terminalCapabilityStore.js +94 -0
  14. package/vscode/src/vs/platform/terminal/common/terminalEnvironment.js +37 -0
  15. package/vscode/src/vs/platform/terminal/common/terminalStrings.js +16 -0
  16. package/vscode/src/vs/platform/terminal/common/xterm/shellIntegrationAddon.js +319 -0
  17. package/vscode/src/vs/workbench/contrib/codeEditor/browser/suggestEnabledInput/suggestEnabledInput.js +91 -1
  18. package/vscode/src/vs/workbench/contrib/format/browser/formatActionsMultiple.js +423 -0
  19. package/vscode/src/vs/workbench/contrib/format/browser/formatActionsNone.js +82 -0
  20. package/vscode/src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.js +564 -11
  21. package/vscode/src/vs/workbench/contrib/scm/common/scm.js +9 -1
  22. package/vscode/src/vs/workbench/contrib/terminal/browser/detachedTerminal.js +67 -0
  23. package/vscode/src/vs/workbench/contrib/terminal/browser/terminalExtensions.js +25 -0
  24. package/vscode/src/vs/workbench/contrib/terminal/browser/terminalIcons.js +64 -0
  25. package/vscode/src/vs/workbench/contrib/terminal/browser/widgets/widgetManager.js +36 -0
  26. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.js +538 -0
  27. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/decorationStyles.js +104 -0
  28. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/markNavigationAddon.js +416 -0
  29. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/suggestAddon.js +390 -0
  30. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.js +799 -0
  31. package/vscode/src/vs/workbench/contrib/testing/common/getComputedState.js +101 -0
  32. package/vscode/src/vs/workbench/contrib/testing/common/observableValue.js +30 -0
  33. package/vscode/src/vs/workbench/contrib/testing/common/storedValue.js +36 -0
  34. package/vscode/src/vs/workbench/contrib/testing/common/testExplorerFilterState.js +116 -0
  35. package/vscode/src/vs/workbench/contrib/testing/common/testProfileService.js +172 -1
  36. package/vscode/src/vs/workbench/contrib/testing/common/testResult.js +384 -0
  37. package/vscode/src/vs/workbench/contrib/testing/common/testResultService.js +156 -1
  38. package/vscode/src/vs/workbench/contrib/testing/common/testResultStorage.js +156 -0
  39. package/vscode/src/vs/workbench/contrib/testing/common/testService.js +75 -1
  40. package/vscode/src/vs/workbench/contrib/testing/common/testTypes.js +9 -1
  41. package/vscode/src/vs/workbench/contrib/testing/common/testingContextKeys.js +179 -0
  42. package/vscode/src/vs/workbench/contrib/testing/common/testingContinuousRunService.js +102 -0
  43. package/vscode/src/vs/workbench/contrib/testing/common/testingDecorations.js +29 -0
  44. package/vscode/src/vs/workbench/contrib/testing/common/testingPeekOpener.js +3 -0
  45. package/vscode/src/vs/workbench/contrib/testing/common/testingStates.js +47 -0
  46. package/vscode/src/vs/workbench/services/authentication/browser/authenticationService.js +594 -2
  47. package/vscode/src/vs/workbench/services/extensions/browser/extensionUrlHandler.js +307 -1
  48. package/vscode/src/vs/workbench/services/suggest/browser/media/suggest.css.js +4 -0
  49. package/vscode/src/vs/workbench/services/suggest/browser/simpleCompletionItem.js +10 -0
  50. package/vscode/src/vs/workbench/services/suggest/browser/simpleCompletionModel.js +98 -0
  51. package/vscode/src/vs/workbench/services/suggest/browser/simpleSuggestWidget.js +428 -0
  52. package/vscode/src/vs/workbench/services/suggest/browser/simpleSuggestWidgetRenderer.js +83 -0
  53. package/vscode/src/vs/workbench/services/textfile/common/textfiles.js +6 -2
@@ -0,0 +1,423 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { getCodeEditor } from 'monaco-editor/esm/vs/editor/browser/editorBrowser.js';
3
+ import { registerEditorAction, EditorAction } from 'monaco-editor/esm/vs/editor/browser/editorExtensions.js';
4
+ import { EditorContextKeys } from 'monaco-editor/esm/vs/editor/common/editorContextKeys.js';
5
+ import * as nls from 'monaco-editor/esm/vs/nls.js';
6
+ import { ContextKeyExpr } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
7
+ import { IQuickInputService } from 'monaco-editor/esm/vs/platform/quickinput/common/quickInput.js';
8
+ import { CancellationToken, CancellationTokenSource } from 'monaco-editor/esm/vs/base/common/cancellation.js';
9
+ import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
10
+ import { FormattingConflicts, getRealAndSyntheticDocumentFormattersOrdered, formatDocumentWithProvider, formatDocumentRangesWithProvider } from 'monaco-editor/esm/vs/editor/contrib/format/browser/format.js';
11
+ import { Range } from 'monaco-editor/esm/vs/editor/common/core/range.js';
12
+ import { ITelemetryService } from 'monaco-editor/esm/vs/platform/telemetry/common/telemetry.js';
13
+ import { ExtensionIdentifier } from 'monaco-editor/esm/vs/platform/extensions/common/extensions.js';
14
+ import { Registry } from 'monaco-editor/esm/vs/platform/registry/common/platform.js';
15
+ import { Extensions as Extensions$1 } from 'monaco-editor/esm/vs/platform/configuration/common/configurationRegistry.js';
16
+ import { Extensions } from '../../../common/contributions.js';
17
+ import { toExtension, IExtensionService } from '../../../services/extensions/common/extensions.js';
18
+ import { Disposable, DisposableStore, toDisposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
19
+ import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
20
+ import { Severity, NotificationPriority, INotificationService } from 'monaco-editor/esm/vs/platform/notification/common/notification.js';
21
+ import { ILanguageService } from 'monaco-editor/esm/vs/editor/common/languages/language.js';
22
+ import { IWorkbenchExtensionEnablementService } from '../../../services/extensionManagement/common/extensionManagement.js';
23
+ import { editorConfigurationBaseNode } from 'monaco-editor/esm/vs/editor/common/config/editorConfigurationSchema.js';
24
+ import '../../../../../../../override/vs/platform/dialogs/common/dialogs.js';
25
+ import { ILanguageFeaturesService } from 'monaco-editor/esm/vs/editor/common/services/languageFeatures.js';
26
+ import { ILanguageStatusService } from '../../../services/languageStatus/common/languageStatusService.js';
27
+ import { IEditorService } from '../../../services/editor/common/editorService.js';
28
+ import { CommandsRegistry } from 'monaco-editor/esm/vs/platform/commands/common/commands.js';
29
+ import { generateUuid } from 'monaco-editor/esm/vs/base/common/uuid.js';
30
+ import { IDialogService } from '../../../../platform/dialogs/common/dialogs.js';
31
+ var DefaultFormatter_1;
32
+ let DefaultFormatter = class DefaultFormatter extends Disposable {
33
+ static { DefaultFormatter_1 = this; }
34
+ static { this.configName = 'editor.defaultFormatter'; }
35
+ static { this.extensionIds = []; }
36
+ static { this.extensionItemLabels = []; }
37
+ static { this.extensionDescriptions = []; }
38
+ constructor(_extensionService, _extensionEnablementService, _configService, _notificationService, _dialogService, _quickInputService, _languageService, _languageFeaturesService, _languageStatusService, _editorService) {
39
+ super();
40
+ this._extensionService = _extensionService;
41
+ this._extensionEnablementService = _extensionEnablementService;
42
+ this._configService = _configService;
43
+ this._notificationService = _notificationService;
44
+ this._dialogService = _dialogService;
45
+ this._quickInputService = _quickInputService;
46
+ this._languageService = _languageService;
47
+ this._languageFeaturesService = _languageFeaturesService;
48
+ this._languageStatusService = _languageStatusService;
49
+ this._editorService = _editorService;
50
+ this._languageStatusStore = this._store.add(( new DisposableStore()));
51
+ this._store.add(this._extensionService.onDidChangeExtensions(this._updateConfigValues, this));
52
+ this._store.add(FormattingConflicts.setFormatterSelector((formatter, document, mode) => this._selectFormatter(formatter, document, mode)));
53
+ this._store.add(_editorService.onDidActiveEditorChange(this._updateStatus, this));
54
+ this._store.add(_languageFeaturesService.documentFormattingEditProvider.onDidChange(this._updateStatus, this));
55
+ this._store.add(_languageFeaturesService.documentRangeFormattingEditProvider.onDidChange(this._updateStatus, this));
56
+ this._store.add(_configService.onDidChangeConfiguration(e => e.affectsConfiguration(DefaultFormatter_1.configName) && this._updateStatus()));
57
+ this._updateConfigValues();
58
+ }
59
+ async _updateConfigValues() {
60
+ await this._extensionService.whenInstalledExtensionsRegistered();
61
+ let extensions = [...this._extensionService.extensions];
62
+ extensions = extensions.sort((a, b) => {
63
+ const boostA = a.categories?.find(cat => cat === 'Formatters' || cat === 'Programming Languages');
64
+ const boostB = b.categories?.find(cat => cat === 'Formatters' || cat === 'Programming Languages');
65
+ if (boostA && !boostB) {
66
+ return -1;
67
+ }
68
+ else if (!boostA && boostB) {
69
+ return 1;
70
+ }
71
+ else {
72
+ return a.name.localeCompare(b.name);
73
+ }
74
+ });
75
+ DefaultFormatter_1.extensionIds.length = 0;
76
+ DefaultFormatter_1.extensionItemLabels.length = 0;
77
+ DefaultFormatter_1.extensionDescriptions.length = 0;
78
+ DefaultFormatter_1.extensionIds.push(null);
79
+ DefaultFormatter_1.extensionItemLabels.push(( nls.localizeWithPath(
80
+ 'vs/workbench/contrib/format/browser/formatActionsMultiple',
81
+ 'null',
82
+ 'None'
83
+ )));
84
+ DefaultFormatter_1.extensionDescriptions.push(( nls.localizeWithPath(
85
+ 'vs/workbench/contrib/format/browser/formatActionsMultiple',
86
+ 'nullFormatterDescription',
87
+ "None"
88
+ )));
89
+ for (const extension of extensions) {
90
+ if (extension.main || extension.browser) {
91
+ DefaultFormatter_1.extensionIds.push(extension.identifier.value);
92
+ DefaultFormatter_1.extensionItemLabels.push(extension.displayName ?? '');
93
+ DefaultFormatter_1.extensionDescriptions.push(extension.description ?? '');
94
+ }
95
+ }
96
+ }
97
+ static _maybeQuotes(s) {
98
+ return s.match(/\s/) ? `'${s}'` : s;
99
+ }
100
+ async _analyzeFormatter(formatter, document) {
101
+ const defaultFormatterId = this._configService.getValue(DefaultFormatter_1.configName, {
102
+ resource: document.uri,
103
+ overrideIdentifier: document.getLanguageId()
104
+ });
105
+ if (defaultFormatterId) {
106
+ const defaultFormatter = formatter.find(formatter => ExtensionIdentifier.equals(formatter.extensionId, defaultFormatterId));
107
+ if (defaultFormatter) {
108
+ return defaultFormatter;
109
+ }
110
+ const extension = await this._extensionService.getExtension(defaultFormatterId);
111
+ if (extension && this._extensionEnablementService.isEnabled(toExtension(extension))) {
112
+ const langName = this._languageService.getLanguageName(document.getLanguageId()) || document.getLanguageId();
113
+ const detail = ( nls.localizeWithPath(
114
+ 'vs/workbench/contrib/format/browser/formatActionsMultiple',
115
+ 'miss',
116
+ "Extension '{0}' is configured as formatter but it cannot format '{1}'-files",
117
+ extension.displayName || extension.name,
118
+ langName
119
+ ));
120
+ return detail;
121
+ }
122
+ }
123
+ else if (formatter.length === 1) {
124
+ return formatter[0];
125
+ }
126
+ const langName = this._languageService.getLanguageName(document.getLanguageId()) || document.getLanguageId();
127
+ const message = !defaultFormatterId
128
+ ? ( nls.localizeWithPath(
129
+ 'vs/workbench/contrib/format/browser/formatActionsMultiple',
130
+ 'config.needed',
131
+ "There are multiple formatters for '{0}' files. One of them should be configured as default formatter.",
132
+ DefaultFormatter_1._maybeQuotes(langName)
133
+ ))
134
+ : ( nls.localizeWithPath(
135
+ 'vs/workbench/contrib/format/browser/formatActionsMultiple',
136
+ 'config.bad',
137
+ "Extension '{0}' is configured as formatter but not available. Select a different default formatter to continue.",
138
+ defaultFormatterId
139
+ ));
140
+ return message;
141
+ }
142
+ async _selectFormatter(formatter, document, mode) {
143
+ const formatterOrMessage = await this._analyzeFormatter(formatter, document);
144
+ if (typeof formatterOrMessage !== 'string') {
145
+ return formatterOrMessage;
146
+ }
147
+ if (mode !== 2 ) {
148
+ const { confirmed } = await this._dialogService.confirm({
149
+ message: ( nls.localizeWithPath(
150
+ 'vs/workbench/contrib/format/browser/formatActionsMultiple',
151
+ 'miss.1',
152
+ "Configure Default Formatter"
153
+ )),
154
+ detail: formatterOrMessage,
155
+ primaryButton: ( nls.localizeWithPath(
156
+ 'vs/workbench/contrib/format/browser/formatActionsMultiple',
157
+ { key: 'do.config', comment: ['&& denotes a mnemonic'] },
158
+ "&&Configure..."
159
+ ))
160
+ });
161
+ if (confirmed) {
162
+ return this._pickAndPersistDefaultFormatter(formatter, document);
163
+ }
164
+ }
165
+ else {
166
+ this._notificationService.prompt(Severity.Info, formatterOrMessage, [{ label: ( nls.localizeWithPath(
167
+ 'vs/workbench/contrib/format/browser/formatActionsMultiple',
168
+ 'do.config.notification',
169
+ "Configure..."
170
+ )), run: () => this._pickAndPersistDefaultFormatter(formatter, document) }], { priority: NotificationPriority.SILENT });
171
+ }
172
+ return undefined;
173
+ }
174
+ async _pickAndPersistDefaultFormatter(formatter, document) {
175
+ const picks = ( formatter.map((formatter, index) => {
176
+ return {
177
+ index,
178
+ label: formatter.displayName || (formatter.extensionId ? formatter.extensionId.value : '?'),
179
+ description: formatter.extensionId && formatter.extensionId.value
180
+ };
181
+ }));
182
+ const langName = this._languageService.getLanguageName(document.getLanguageId()) || document.getLanguageId();
183
+ const pick = await this._quickInputService.pick(picks, { placeHolder: ( nls.localizeWithPath(
184
+ 'vs/workbench/contrib/format/browser/formatActionsMultiple',
185
+ 'select',
186
+ "Select a default formatter for '{0}' files",
187
+ DefaultFormatter_1._maybeQuotes(langName)
188
+ )) });
189
+ if (!pick || !formatter[pick.index].extensionId) {
190
+ return undefined;
191
+ }
192
+ this._configService.updateValue(DefaultFormatter_1.configName, formatter[pick.index].extensionId.value, {
193
+ resource: document.uri,
194
+ overrideIdentifier: document.getLanguageId()
195
+ });
196
+ return formatter[pick.index];
197
+ }
198
+ _updateStatus() {
199
+ this._languageStatusStore.clear();
200
+ const editor = getCodeEditor(this._editorService.activeTextEditorControl);
201
+ if (!editor || !editor.hasModel()) {
202
+ return;
203
+ }
204
+ const document = editor.getModel();
205
+ const formatter = getRealAndSyntheticDocumentFormattersOrdered(this._languageFeaturesService.documentFormattingEditProvider, this._languageFeaturesService.documentRangeFormattingEditProvider, document);
206
+ if (formatter.length === 0) {
207
+ return;
208
+ }
209
+ const cts = ( new CancellationTokenSource());
210
+ this._languageStatusStore.add(toDisposable(() => cts.dispose(true)));
211
+ this._analyzeFormatter(formatter, document).then(result => {
212
+ if (cts.token.isCancellationRequested) {
213
+ return;
214
+ }
215
+ if (typeof result !== 'string') {
216
+ return;
217
+ }
218
+ const command = { id: `formatter/configure/dfl/${generateUuid()}`, title: ( nls.localizeWithPath(
219
+ 'vs/workbench/contrib/format/browser/formatActionsMultiple',
220
+ 'do.config.command',
221
+ "Configure..."
222
+ )) };
223
+ this._languageStatusStore.add(CommandsRegistry.registerCommand(command.id, () => this._pickAndPersistDefaultFormatter(formatter, document)));
224
+ this._languageStatusStore.add(this._languageStatusService.addStatus({
225
+ id: 'formatter.conflict',
226
+ name: ( nls.localizeWithPath(
227
+ 'vs/workbench/contrib/format/browser/formatActionsMultiple',
228
+ 'summary',
229
+ "Formatter Conflicts"
230
+ )),
231
+ selector: { language: document.getLanguageId(), pattern: document.uri.fsPath },
232
+ severity: Severity.Error,
233
+ label: ( nls.localizeWithPath(
234
+ 'vs/workbench/contrib/format/browser/formatActionsMultiple',
235
+ 'formatter',
236
+ "Formatting"
237
+ )),
238
+ detail: result,
239
+ busy: false,
240
+ source: '',
241
+ command,
242
+ accessibilityInfo: undefined
243
+ }));
244
+ });
245
+ }
246
+ };
247
+ DefaultFormatter = DefaultFormatter_1 = ( __decorate([
248
+ ( __param(0, IExtensionService)),
249
+ ( __param(1, IWorkbenchExtensionEnablementService)),
250
+ ( __param(2, IConfigurationService)),
251
+ ( __param(3, INotificationService)),
252
+ ( __param(4, IDialogService)),
253
+ ( __param(5, IQuickInputService)),
254
+ ( __param(6, ILanguageService)),
255
+ ( __param(7, ILanguageFeaturesService)),
256
+ ( __param(8, ILanguageStatusService)),
257
+ ( __param(9, IEditorService))
258
+ ], DefaultFormatter));
259
+ ( Registry.as(Extensions.Workbench)).registerWorkbenchContribution(DefaultFormatter, 3 );
260
+ ( Registry.as(Extensions$1.Configuration)).registerConfiguration({
261
+ ...editorConfigurationBaseNode,
262
+ properties: {
263
+ [DefaultFormatter.configName]: {
264
+ description: ( nls.localizeWithPath(
265
+ 'vs/workbench/contrib/format/browser/formatActionsMultiple',
266
+ 'formatter.default',
267
+ "Defines a default formatter which takes precedence over all other formatter settings. Must be the identifier of an extension contributing a formatter."
268
+ )),
269
+ type: ['string', 'null'],
270
+ default: null,
271
+ enum: DefaultFormatter.extensionIds,
272
+ enumItemLabels: DefaultFormatter.extensionItemLabels,
273
+ markdownEnumDescriptions: DefaultFormatter.extensionDescriptions
274
+ }
275
+ }
276
+ });
277
+ function logFormatterTelemetry(telemetryService, mode, options, pick) {
278
+ function extKey(obj) {
279
+ return obj.extensionId ? ExtensionIdentifier.toKey(obj.extensionId) : 'unknown';
280
+ }
281
+ telemetryService.publicLog2('formatterpick', {
282
+ mode,
283
+ extensions: ( options.map(extKey)),
284
+ pick: pick ? extKey(pick) : 'none'
285
+ });
286
+ }
287
+ async function showFormatterPick(accessor, model, formatters) {
288
+ const quickPickService = accessor.get(IQuickInputService);
289
+ const configService = accessor.get(IConfigurationService);
290
+ const languageService = accessor.get(ILanguageService);
291
+ const overrides = { resource: model.uri, overrideIdentifier: model.getLanguageId() };
292
+ const defaultFormatter = configService.getValue(DefaultFormatter.configName, overrides);
293
+ let defaultFormatterPick;
294
+ const picks = ( formatters.map((provider, index) => {
295
+ const isDefault = ExtensionIdentifier.equals(provider.extensionId, defaultFormatter);
296
+ const pick = {
297
+ index,
298
+ label: provider.displayName || '',
299
+ description: isDefault ? ( nls.localizeWithPath(
300
+ 'vs/workbench/contrib/format/browser/formatActionsMultiple',
301
+ 'def',
302
+ "(default)"
303
+ )) : undefined,
304
+ };
305
+ if (isDefault) {
306
+ defaultFormatterPick = pick;
307
+ }
308
+ return pick;
309
+ }));
310
+ const configurePick = {
311
+ label: ( nls.localizeWithPath(
312
+ 'vs/workbench/contrib/format/browser/formatActionsMultiple',
313
+ 'config',
314
+ "Configure Default Formatter..."
315
+ ))
316
+ };
317
+ const pick = await quickPickService.pick([...picks, { type: 'separator' }, configurePick], {
318
+ placeHolder: ( nls.localizeWithPath(
319
+ 'vs/workbench/contrib/format/browser/formatActionsMultiple',
320
+ 'format.placeHolder',
321
+ "Select a formatter"
322
+ )),
323
+ activeItem: defaultFormatterPick
324
+ });
325
+ if (!pick) {
326
+ return undefined;
327
+ }
328
+ else if (pick === configurePick) {
329
+ const langName = languageService.getLanguageName(model.getLanguageId()) || model.getLanguageId();
330
+ const pick = await quickPickService.pick(picks, { placeHolder: ( nls.localizeWithPath(
331
+ 'vs/workbench/contrib/format/browser/formatActionsMultiple',
332
+ 'select',
333
+ "Select a default formatter for '{0}' files",
334
+ DefaultFormatter._maybeQuotes(langName)
335
+ )) });
336
+ if (pick && formatters[pick.index].extensionId) {
337
+ configService.updateValue(DefaultFormatter.configName, formatters[pick.index].extensionId.value, overrides);
338
+ }
339
+ return undefined;
340
+ }
341
+ else {
342
+ return pick.index;
343
+ }
344
+ }
345
+ registerEditorAction(class FormatDocumentMultipleAction extends EditorAction {
346
+ constructor() {
347
+ super({
348
+ id: 'editor.action.formatDocument.multiple',
349
+ label: ( nls.localizeWithPath(
350
+ 'vs/workbench/contrib/format/browser/formatActionsMultiple',
351
+ 'formatDocument.label.multiple',
352
+ "Format Document With..."
353
+ )),
354
+ alias: 'Format Document...',
355
+ precondition: ( ContextKeyExpr.and(
356
+ EditorContextKeys.writable,
357
+ EditorContextKeys.hasMultipleDocumentFormattingProvider
358
+ )),
359
+ contextMenuOpts: {
360
+ group: '1_modification',
361
+ order: 1.3
362
+ }
363
+ });
364
+ }
365
+ async run(accessor, editor, args) {
366
+ if (!editor.hasModel()) {
367
+ return;
368
+ }
369
+ const instaService = accessor.get(IInstantiationService);
370
+ const telemetryService = accessor.get(ITelemetryService);
371
+ const languageFeaturesService = accessor.get(ILanguageFeaturesService);
372
+ const model = editor.getModel();
373
+ const provider = getRealAndSyntheticDocumentFormattersOrdered(languageFeaturesService.documentFormattingEditProvider, languageFeaturesService.documentRangeFormattingEditProvider, model);
374
+ const pick = await instaService.invokeFunction(showFormatterPick, model, provider);
375
+ if (typeof pick === 'number') {
376
+ await instaService.invokeFunction(formatDocumentWithProvider, provider[pick], editor, 1 , CancellationToken.None);
377
+ }
378
+ logFormatterTelemetry(telemetryService, 'document', provider, typeof pick === 'number' && provider[pick] || undefined);
379
+ }
380
+ });
381
+ registerEditorAction(class FormatSelectionMultipleAction extends EditorAction {
382
+ constructor() {
383
+ super({
384
+ id: 'editor.action.formatSelection.multiple',
385
+ label: ( nls.localizeWithPath(
386
+ 'vs/workbench/contrib/format/browser/formatActionsMultiple',
387
+ 'formatSelection.label.multiple',
388
+ "Format Selection With..."
389
+ )),
390
+ alias: 'Format Code...',
391
+ precondition: ( ContextKeyExpr.and(( ContextKeyExpr.and(EditorContextKeys.writable)), EditorContextKeys.hasMultipleDocumentSelectionFormattingProvider)),
392
+ contextMenuOpts: {
393
+ when: ( ContextKeyExpr.and(EditorContextKeys.hasNonEmptySelection)),
394
+ group: '1_modification',
395
+ order: 1.31
396
+ }
397
+ });
398
+ }
399
+ async run(accessor, editor) {
400
+ if (!editor.hasModel()) {
401
+ return;
402
+ }
403
+ const instaService = accessor.get(IInstantiationService);
404
+ const languageFeaturesService = accessor.get(ILanguageFeaturesService);
405
+ const telemetryService = accessor.get(ITelemetryService);
406
+ const model = editor.getModel();
407
+ let range = editor.getSelection();
408
+ if (range.isEmpty()) {
409
+ range = ( new Range(
410
+ range.startLineNumber,
411
+ 1,
412
+ range.startLineNumber,
413
+ model.getLineMaxColumn(range.startLineNumber)
414
+ ));
415
+ }
416
+ const provider = languageFeaturesService.documentRangeFormattingEditProvider.ordered(model);
417
+ const pick = await instaService.invokeFunction(showFormatterPick, model, provider);
418
+ if (typeof pick === 'number') {
419
+ await instaService.invokeFunction(formatDocumentRangesWithProvider, provider[pick], editor, range, CancellationToken.None);
420
+ }
421
+ logFormatterTelemetry(telemetryService, 'range', provider, typeof pick === 'number' && provider[pick] || undefined);
422
+ }
423
+ });
@@ -0,0 +1,82 @@
1
+ import { registerEditorAction, EditorAction } from 'monaco-editor/esm/vs/editor/browser/editorExtensions.js';
2
+ import { EditorContextKeys } from 'monaco-editor/esm/vs/editor/common/editorContextKeys.js';
3
+ import * as nls from 'monaco-editor/esm/vs/nls.js';
4
+ import { ContextKeyExpr } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
5
+ import { ICommandService } from 'monaco-editor/esm/vs/platform/commands/common/commands.js';
6
+ import { INotificationService } from 'monaco-editor/esm/vs/platform/notification/common/notification.js';
7
+ import { VIEWLET_ID } from '../../extensions/common/extensions.js';
8
+ import '../../../../../../../override/vs/platform/dialogs/common/dialogs.js';
9
+ import { IPaneCompositePartService } from '../../../services/panecomposite/browser/panecomposite.js';
10
+ import { ILanguageFeaturesService } from 'monaco-editor/esm/vs/editor/common/services/languageFeatures.js';
11
+ import { IDialogService } from '../../../../platform/dialogs/common/dialogs.js';
12
+ async function showExtensionQuery(paneCompositeService, query) {
13
+ const viewlet = await paneCompositeService.openPaneComposite(VIEWLET_ID, 0 , true);
14
+ if (viewlet) {
15
+ (viewlet?.getViewPaneContainer()).search(query);
16
+ }
17
+ }
18
+ registerEditorAction(class FormatDocumentMultipleAction extends EditorAction {
19
+ constructor() {
20
+ super({
21
+ id: 'editor.action.formatDocument.none',
22
+ label: ( nls.localizeWithPath(
23
+ 'vs/workbench/contrib/format/browser/formatActionsNone',
24
+ 'formatDocument.label.multiple',
25
+ "Format Document"
26
+ )),
27
+ alias: 'Format Document',
28
+ precondition: ( ContextKeyExpr.and(EditorContextKeys.writable, ( EditorContextKeys.hasDocumentFormattingProvider.toNegated()))),
29
+ kbOpts: {
30
+ kbExpr: EditorContextKeys.editorTextFocus,
31
+ primary: 1024 | 512 | 36 ,
32
+ linux: { primary: 2048 | 1024 | 39 },
33
+ weight: 100 ,
34
+ }
35
+ });
36
+ }
37
+ async run(accessor, editor) {
38
+ if (!editor.hasModel()) {
39
+ return;
40
+ }
41
+ const commandService = accessor.get(ICommandService);
42
+ const paneCompositeService = accessor.get(IPaneCompositePartService);
43
+ const notificationService = accessor.get(INotificationService);
44
+ const dialogService = accessor.get(IDialogService);
45
+ const languageFeaturesService = accessor.get(ILanguageFeaturesService);
46
+ const model = editor.getModel();
47
+ const formatterCount = languageFeaturesService.documentFormattingEditProvider.all(model).length;
48
+ if (formatterCount > 1) {
49
+ return commandService.executeCommand('editor.action.formatDocument.multiple');
50
+ }
51
+ else if (formatterCount === 1) {
52
+ return commandService.executeCommand('editor.action.formatDocument');
53
+ }
54
+ else if (model.isTooLargeForSyncing()) {
55
+ notificationService.warn(( nls.localizeWithPath(
56
+ 'vs/workbench/contrib/format/browser/formatActionsNone',
57
+ 'too.large',
58
+ "This file cannot be formatted because it is too large"
59
+ )));
60
+ }
61
+ else {
62
+ const langName = model.getLanguageId();
63
+ const message = ( nls.localizeWithPath(
64
+ 'vs/workbench/contrib/format/browser/formatActionsNone',
65
+ 'no.provider',
66
+ "There is no formatter for '{0}' files installed.",
67
+ langName
68
+ ));
69
+ const { confirmed } = await dialogService.confirm({
70
+ message,
71
+ primaryButton: ( nls.localizeWithPath(
72
+ 'vs/workbench/contrib/format/browser/formatActionsNone',
73
+ { key: 'install.formatter', comment: ['&& denotes a mnemonic'] },
74
+ "&&Install Formatter..."
75
+ ))
76
+ });
77
+ if (confirmed) {
78
+ showExtensionQuery(paneCompositeService, `category:formatters ${langName}`);
79
+ }
80
+ }
81
+ }
82
+ });