@codingame/monaco-vscode-view-common-service-override 4.5.0-improve-code-splitting.1

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 (114) hide show
  1. package/assets/fake.html +10 -0
  2. package/assets/index-no-csp.html +1230 -0
  3. package/assets/index.html +1231 -0
  4. package/assets/service-worker.js +457 -0
  5. package/index.d.ts +1 -0
  6. package/index.js +1 -0
  7. package/override/vs/workbench/browser/parts/editor/textEditor.js +5 -0
  8. package/override/vs/workbench/browser/parts/editor/textEditor.weak.js +11 -0
  9. package/package.json +32 -0
  10. package/tools/editorAssets.js +4 -0
  11. package/tools/url.js +10 -0
  12. package/viewCommon.d.ts +5 -0
  13. package/viewCommon.js +105 -0
  14. package/vscode/src/vs/base/browser/deviceAccess.js +61 -0
  15. package/vscode/src/vs/base/browser/ui/centered/centeredViewLayout.js +180 -0
  16. package/vscode/src/vs/base/browser/ui/grid/grid.js +494 -0
  17. package/vscode/src/vs/base/browser/ui/grid/gridview.css.js +6 -0
  18. package/vscode/src/vs/base/browser/ui/grid/gridview.js +1113 -0
  19. package/vscode/src/vs/platform/languagePacks/common/localizedStrings.js +12 -0
  20. package/vscode/src/vs/platform/webview/common/mimeTypes.js +24 -0
  21. package/vscode/src/vs/platform/webview/common/webviewPortMapping.js +64 -0
  22. package/vscode/src/vs/workbench/api/browser/viewsExtensionPoint.js +907 -0
  23. package/vscode/src/vs/workbench/browser/actions/listCommands.js +764 -0
  24. package/vscode/src/vs/workbench/browser/actions/navigationActions.js +301 -0
  25. package/vscode/src/vs/workbench/browser/media/style.css.js +6 -0
  26. package/vscode/src/vs/workbench/browser/parts/activitybar/activitybarPart.js +671 -0
  27. package/vscode/src/vs/workbench/browser/parts/activitybar/media/activityaction.css.js +6 -0
  28. package/vscode/src/vs/workbench/browser/parts/activitybar/media/activitybarpart.css.js +6 -0
  29. package/vscode/src/vs/workbench/browser/parts/auxiliarybar/auxiliaryBarPart.js +229 -0
  30. package/vscode/src/vs/workbench/browser/parts/auxiliarybar/media/auxiliaryBarPart.css.js +6 -0
  31. package/vscode/src/vs/workbench/browser/parts/compositeBar.js +606 -0
  32. package/vscode/src/vs/workbench/browser/parts/compositePart.js +346 -0
  33. package/vscode/src/vs/workbench/browser/parts/editor/auxiliaryEditorPart.js +246 -0
  34. package/vscode/src/vs/workbench/browser/parts/editor/editor.contribution.js +1403 -0
  35. package/vscode/src/vs/workbench/browser/parts/editor/editorConfiguration.js +188 -0
  36. package/vscode/src/vs/workbench/browser/parts/editor/editorDropTarget.js +523 -0
  37. package/vscode/src/vs/workbench/browser/parts/editor/editorPart.js +1030 -0
  38. package/vscode/src/vs/workbench/browser/parts/editor/editorParts.js +391 -0
  39. package/vscode/src/vs/workbench/browser/parts/editor/media/editordroptarget.css.js +6 -0
  40. package/vscode/src/vs/workbench/browser/parts/media/compositepart.css.js +6 -0
  41. package/vscode/src/vs/workbench/browser/parts/media/paneCompositePart.css.js +6 -0
  42. package/vscode/src/vs/workbench/browser/parts/paneCompositeBar.js +643 -0
  43. package/vscode/src/vs/workbench/browser/parts/paneCompositePart.js +472 -0
  44. package/vscode/src/vs/workbench/browser/parts/paneCompositePartService.js +68 -0
  45. package/vscode/src/vs/workbench/browser/parts/panel/panelPart.js +160 -0
  46. package/vscode/src/vs/workbench/browser/parts/sidebar/media/sidebarpart.css.js +6 -0
  47. package/vscode/src/vs/workbench/browser/parts/sidebar/sidebarActions.js +39 -0
  48. package/vscode/src/vs/workbench/browser/parts/sidebar/sidebarPart.js +238 -0
  49. package/vscode/src/vs/workbench/browser/style.js +54 -0
  50. package/vscode/src/vs/workbench/browser/window.js +381 -0
  51. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchy.contribution.js +300 -0
  52. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyPeek.js +367 -0
  53. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyTree.js +135 -0
  54. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/media/callHierarchy.css.js +6 -0
  55. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditor.contribution.js +18 -0
  56. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.js +146 -0
  57. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditors.js +215 -0
  58. package/vscode/src/vs/workbench/contrib/customEditor/browser/media/customEditor.css.js +6 -0
  59. package/vscode/src/vs/workbench/contrib/customEditor/common/contributedCustomEditors.js +78 -0
  60. package/vscode/src/vs/workbench/contrib/customEditor/common/customEditor.js +56 -0
  61. package/vscode/src/vs/workbench/contrib/customEditor/common/customEditorModelManager.js +63 -0
  62. package/vscode/src/vs/workbench/contrib/customEditor/common/extensionPoint.js +183 -0
  63. package/vscode/src/vs/workbench/contrib/externalUriOpener/common/externalUriOpener.contribution.js +8 -0
  64. package/vscode/src/vs/workbench/contrib/languageStatus/browser/languageStatus.contribution.js +408 -0
  65. package/vscode/src/vs/workbench/contrib/languageStatus/browser/media/languageStatus.css.js +6 -0
  66. package/vscode/src/vs/workbench/contrib/limitIndicator/browser/limitIndicator.contribution.js +147 -0
  67. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/commands.js +635 -0
  68. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/devCommands.js +230 -0
  69. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditor.contribution.js +75 -0
  70. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorSerializer.js +42 -0
  71. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/colors.js +81 -0
  72. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/conflictActions.js +350 -0
  73. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editorGutter.js +100 -0
  74. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/baseCodeEditorView.js +148 -0
  75. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/codeEditorView.js +106 -0
  76. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/inputCodeEditorView.js +403 -0
  77. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/resultCodeEditorView.js +199 -0
  78. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/fixedZoneWidget.js +41 -0
  79. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/lineAlignment.js +128 -0
  80. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/media/mergeEditor.css.js +6 -0
  81. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/mergeEditor.js +619 -0
  82. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/scrollSynchronizer.js +161 -0
  83. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/viewModel.js +266 -0
  84. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/viewZones.js +173 -0
  85. package/vscode/src/vs/workbench/contrib/preferences/browser/keyboardLayoutPicker.js +195 -0
  86. package/vscode/src/vs/workbench/contrib/sash/browser/sash.contribution.js +38 -0
  87. package/vscode/src/vs/workbench/contrib/sash/browser/sash.js +41 -0
  88. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/media/typeHierarchy.css.js +6 -0
  89. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchy.contribution.js +283 -0
  90. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyPeek.js +362 -0
  91. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyTree.js +133 -0
  92. package/vscode/src/vs/workbench/contrib/webview/browser/overlayWebview.js +314 -0
  93. package/vscode/src/vs/workbench/contrib/webview/browser/resourceLoading.js +96 -0
  94. package/vscode/src/vs/workbench/contrib/webview/browser/themeing.js +98 -0
  95. package/vscode/src/vs/workbench/contrib/webview/browser/webviewElement.js +656 -0
  96. package/vscode/src/vs/workbench/contrib/webview/browser/webviewFindWidget.js +65 -0
  97. package/vscode/src/vs/workbench/contrib/webview/browser/webviewService.js +59 -0
  98. package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewCommands.js +143 -0
  99. package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewEditorInputSerializer.js +121 -0
  100. package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewPanel.contribution.js +67 -0
  101. package/vscode/src/vs/workbench/contrib/webviewView/browser/webviewViewPane.js +234 -0
  102. package/vscode/src/vs/workbench/contrib/webviewView/browser/webviewViewService.js +45 -0
  103. package/vscode/src/vs/workbench/services/activity/browser/activityService.js +145 -0
  104. package/vscode/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.js +341 -0
  105. package/vscode/src/vs/workbench/services/driver/browser/driver.js +186 -0
  106. package/vscode/src/vs/workbench/services/editor/browser/editorPaneService.js +13 -0
  107. package/vscode/src/vs/workbench/services/editor/browser/editorResolverService.js +676 -0
  108. package/vscode/src/vs/workbench/services/history/browser/historyService.js +1516 -0
  109. package/vscode/src/vs/workbench/services/progress/browser/media/progressService.css.js +6 -0
  110. package/vscode/src/vs/workbench/services/progress/browser/progressService.js +527 -0
  111. package/vscode/src/vs/workbench/services/untitled/common/untitledTextEditorHandler.js +102 -0
  112. package/vscode/src/vs/workbench/services/untitled/common/untitledTextEditorService.js +133 -0
  113. package/vscode/src/vs/workbench/services/views/browser/viewDescriptorService.js +711 -0
  114. package/vscode/src/vs/workbench/services/views/common/viewContainerModel.js +603 -0
@@ -0,0 +1,676 @@
1
+ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
+ import { isRelativePattern } from 'vscode/vscode/vs/base/common/glob';
3
+ import { insert, flatten, distinct, firstOrDefault } from 'vscode/vscode/vs/base/common/arrays';
4
+ import { Disposable, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
5
+ import { isEqual, extname, basename } from 'vscode/vscode/vs/base/common/resources';
6
+ import { URI } from 'vscode/vscode/vs/base/common/uri';
7
+ import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
8
+ import { EditorResolution, EditorActivation } from 'vscode/vscode/vs/platform/editor/common/editor';
9
+ import { isResourceSideBySideEditorInput, EditorResourceAccessor, SideBySideEditor, isEditorInputWithOptions, DEFAULT_EDITOR_ASSOCIATION, isResourceDiffEditorInput, isEditorInputWithOptionsAndGroup, isResourceMergeEditorInput, isResourceMultiDiffEditorInput, isUntitledResourceEditorInput } from 'vscode/vscode/vs/workbench/common/editor';
10
+ import { IEditorGroupsService } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService.service';
11
+ import { Schemas } from 'vscode/vscode/vs/base/common/network';
12
+ import { globMatchesResource, editorsAssociationsSettingId, RegisteredEditorPriority, priorityToRank } from 'vscode/vscode/vs/workbench/services/editor/common/editorResolverService';
13
+ import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
14
+ import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput.service';
15
+ import { localizeWithPath } from 'vscode/vscode/vs/nls';
16
+ import 'vscode/vscode/vs/platform/notification/common/notification';
17
+ import { INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification.service';
18
+ import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
19
+ import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
20
+ import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions.service';
21
+ import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
22
+ import { findGroup } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupFinder';
23
+ import { SideBySideEditorInput } from 'vscode/vscode/vs/workbench/common/editor/sideBySideEditorInput';
24
+ import { PauseableEmitter } from 'vscode/vscode/vs/base/common/event';
25
+ import Severity$1 from 'vscode/vscode/vs/base/common/severity';
26
+
27
+ var EditorResolverService_1;
28
+ let EditorResolverService = class EditorResolverService extends Disposable {
29
+ static { EditorResolverService_1 = this; }
30
+ static { this.configureDefaultID = 'promptOpenWith.configureDefault'; }
31
+ static { this.cacheStorageID = 'editorOverrideService.cache'; }
32
+ static { this.conflictingDefaultsStorageID = 'editorOverrideService.conflictingDefaults'; }
33
+ constructor(editorGroupService, instantiationService, configurationService, quickInputService, notificationService, telemetryService, storageService, extensionService, logService) {
34
+ super();
35
+ this.editorGroupService = editorGroupService;
36
+ this.instantiationService = instantiationService;
37
+ this.configurationService = configurationService;
38
+ this.quickInputService = quickInputService;
39
+ this.notificationService = notificationService;
40
+ this.telemetryService = telemetryService;
41
+ this.storageService = storageService;
42
+ this.extensionService = extensionService;
43
+ this.logService = logService;
44
+ this._onDidChangeEditorRegistrations = this._register(( new PauseableEmitter()));
45
+ this.onDidChangeEditorRegistrations = this._onDidChangeEditorRegistrations.event;
46
+ this._editors = ( new Map());
47
+ this._flattenedEditors = ( new Map());
48
+ this._shouldReFlattenEditors = true;
49
+ this.cache = ( new Set(
50
+ JSON.parse(this.storageService.get(EditorResolverService_1.cacheStorageID, 0 , JSON.stringify([])))
51
+ ));
52
+ this.storageService.remove(EditorResolverService_1.cacheStorageID, 0 );
53
+ this._register(this.storageService.onWillSaveState(() => {
54
+ this.cacheEditors();
55
+ }));
56
+ this._register(this.extensionService.onDidRegisterExtensions(() => {
57
+ this.cache = undefined;
58
+ }));
59
+ }
60
+ resolveUntypedInputAndGroup(editor, preferredGroup) {
61
+ const untypedEditor = editor;
62
+ const findGroupResult = this.instantiationService.invokeFunction(findGroup, untypedEditor, preferredGroup);
63
+ if (findGroupResult instanceof Promise) {
64
+ return findGroupResult.then(([group, activation]) => [untypedEditor, group, activation]);
65
+ }
66
+ else {
67
+ const [group, activation] = findGroupResult;
68
+ return [untypedEditor, group, activation];
69
+ }
70
+ }
71
+ async resolveEditor(editor, preferredGroup) {
72
+ this._flattenedEditors = this._flattenEditorsMap();
73
+ if (isResourceSideBySideEditorInput(editor)) {
74
+ return this.doResolveSideBySideEditor(editor, preferredGroup);
75
+ }
76
+ let resolvedUntypedAndGroup;
77
+ const resolvedUntypedAndGroupResult = this.resolveUntypedInputAndGroup(editor, preferredGroup);
78
+ if (resolvedUntypedAndGroupResult instanceof Promise) {
79
+ resolvedUntypedAndGroup = await resolvedUntypedAndGroupResult;
80
+ }
81
+ else {
82
+ resolvedUntypedAndGroup = resolvedUntypedAndGroupResult;
83
+ }
84
+ if (!resolvedUntypedAndGroup) {
85
+ return 2 ;
86
+ }
87
+ const [untypedEditor, group, activation] = resolvedUntypedAndGroup;
88
+ if (activation) {
89
+ untypedEditor.options = { ...untypedEditor.options, activation };
90
+ }
91
+ let resource = EditorResourceAccessor.getCanonicalUri(untypedEditor, { supportSideBySide: SideBySideEditor.PRIMARY });
92
+ if (this.cache && resource && this.resourceMatchesCache(resource)) {
93
+ await this.extensionService.whenInstalledExtensionsRegistered();
94
+ }
95
+ if (resource === undefined) {
96
+ resource = ( URI.from({ scheme: Schemas.untitled }));
97
+ }
98
+ else if (resource.scheme === undefined || resource === null) {
99
+ return 2 ;
100
+ }
101
+ if (untypedEditor.options?.override === EditorResolution.PICK) {
102
+ const picked = await this.doPickEditor(untypedEditor);
103
+ if (!picked) {
104
+ return 1 ;
105
+ }
106
+ untypedEditor.options = picked;
107
+ }
108
+ let { editor: selectedEditor, conflictingDefault } = this.getEditor(resource, untypedEditor.options?.override);
109
+ if (!selectedEditor && (untypedEditor.options?.override || isEditorInputWithOptions(editor))) {
110
+ return 2 ;
111
+ }
112
+ else if (!selectedEditor) {
113
+ const resolvedEditor = this.getEditor(resource, DEFAULT_EDITOR_ASSOCIATION.id);
114
+ selectedEditor = resolvedEditor?.editor;
115
+ conflictingDefault = resolvedEditor?.conflictingDefault;
116
+ if (!selectedEditor) {
117
+ return 2 ;
118
+ }
119
+ }
120
+ if (isResourceDiffEditorInput(untypedEditor) && untypedEditor.options?.override === undefined) {
121
+ let resource2 = EditorResourceAccessor.getCanonicalUri(untypedEditor, { supportSideBySide: SideBySideEditor.SECONDARY });
122
+ if (!resource2) {
123
+ resource2 = ( URI.from({ scheme: Schemas.untitled }));
124
+ }
125
+ const { editor: selectedEditor2 } = this.getEditor(resource2, undefined);
126
+ if (!selectedEditor2 || selectedEditor.editorInfo.id !== selectedEditor2.editorInfo.id) {
127
+ const { editor: selectedDiff, conflictingDefault: conflictingDefaultDiff } = this.getEditor(resource, DEFAULT_EDITOR_ASSOCIATION.id);
128
+ selectedEditor = selectedDiff;
129
+ conflictingDefault = conflictingDefaultDiff;
130
+ }
131
+ if (!selectedEditor) {
132
+ return 2 ;
133
+ }
134
+ }
135
+ untypedEditor.options = { override: selectedEditor.editorInfo.id, ...untypedEditor.options };
136
+ if (selectedEditor.editorFactoryObject.createDiffEditorInput === undefined && isResourceDiffEditorInput(untypedEditor)) {
137
+ return 2 ;
138
+ }
139
+ const input = await this.doResolveEditor(untypedEditor, group, selectedEditor);
140
+ if (conflictingDefault && input) {
141
+ await this.doHandleConflictingDefaults(resource, selectedEditor.editorInfo.label, untypedEditor, input.editor, group);
142
+ }
143
+ if (input) {
144
+ this.sendEditorResolutionTelemetry(input.editor);
145
+ if (input.editor.editorId !== selectedEditor.editorInfo.id) {
146
+ this.logService.warn(`Editor ID Mismatch: ${input.editor.editorId} !== ${selectedEditor.editorInfo.id}. This will cause bugs. Please ensure editorInput.editorId matches the registered id`);
147
+ }
148
+ return { ...input, group };
149
+ }
150
+ return 1 ;
151
+ }
152
+ async doResolveSideBySideEditor(editor, preferredGroup) {
153
+ const primaryResolvedEditor = await this.resolveEditor(editor.primary, preferredGroup);
154
+ if (!isEditorInputWithOptionsAndGroup(primaryResolvedEditor)) {
155
+ return 2 ;
156
+ }
157
+ const secondaryResolvedEditor = await this.resolveEditor(editor.secondary, primaryResolvedEditor.group ?? preferredGroup);
158
+ if (!isEditorInputWithOptionsAndGroup(secondaryResolvedEditor)) {
159
+ return 2 ;
160
+ }
161
+ return {
162
+ group: primaryResolvedEditor.group ?? secondaryResolvedEditor.group,
163
+ editor: this.instantiationService.createInstance(SideBySideEditorInput, editor.label, editor.description, secondaryResolvedEditor.editor, primaryResolvedEditor.editor),
164
+ options: editor.options
165
+ };
166
+ }
167
+ bufferChangeEvents(callback) {
168
+ this._onDidChangeEditorRegistrations.pause();
169
+ try {
170
+ callback();
171
+ }
172
+ finally {
173
+ this._onDidChangeEditorRegistrations.resume();
174
+ }
175
+ }
176
+ registerEditor(globPattern, editorInfo, options, editorFactoryObject) {
177
+ let registeredEditor = this._editors.get(globPattern);
178
+ if (registeredEditor === undefined) {
179
+ registeredEditor = ( new Map());
180
+ this._editors.set(globPattern, registeredEditor);
181
+ }
182
+ let editorsWithId = registeredEditor.get(editorInfo.id);
183
+ if (editorsWithId === undefined) {
184
+ editorsWithId = [];
185
+ }
186
+ const remove = insert(editorsWithId, {
187
+ globPattern,
188
+ editorInfo,
189
+ options,
190
+ editorFactoryObject
191
+ });
192
+ registeredEditor.set(editorInfo.id, editorsWithId);
193
+ this._shouldReFlattenEditors = true;
194
+ this._onDidChangeEditorRegistrations.fire();
195
+ return toDisposable(() => {
196
+ remove();
197
+ if (editorsWithId && editorsWithId.length === 0) {
198
+ registeredEditor?.delete(editorInfo.id);
199
+ }
200
+ this._shouldReFlattenEditors = true;
201
+ this._onDidChangeEditorRegistrations.fire();
202
+ });
203
+ }
204
+ getAssociationsForResource(resource) {
205
+ const associations = this.getAllUserAssociations();
206
+ let matchingAssociations = associations.filter(association => association.filenamePattern && globMatchesResource(association.filenamePattern, resource));
207
+ matchingAssociations = matchingAssociations.sort((a, b) => (b.filenamePattern?.length ?? 0) - (a.filenamePattern?.length ?? 0));
208
+ const allEditors = this._registeredEditors;
209
+ return matchingAssociations.filter(association => allEditors.find(c => c.editorInfo.id === association.viewType));
210
+ }
211
+ getAllUserAssociations() {
212
+ const inspectedEditorAssociations = this.configurationService.inspect(editorsAssociationsSettingId) || {};
213
+ const defaultAssociations = inspectedEditorAssociations.defaultValue ?? {};
214
+ const workspaceAssociations = inspectedEditorAssociations.workspaceValue ?? {};
215
+ const userAssociations = inspectedEditorAssociations.userValue ?? {};
216
+ const rawAssociations = { ...workspaceAssociations };
217
+ for (const [key, value] of Object.entries({ ...defaultAssociations, ...userAssociations })) {
218
+ if (rawAssociations[key] === undefined) {
219
+ rawAssociations[key] = value;
220
+ }
221
+ }
222
+ const associations = [];
223
+ for (const [key, value] of Object.entries(rawAssociations)) {
224
+ const association = {
225
+ filenamePattern: key,
226
+ viewType: value
227
+ };
228
+ associations.push(association);
229
+ }
230
+ return associations;
231
+ }
232
+ _flattenEditorsMap() {
233
+ if (!this._shouldReFlattenEditors) {
234
+ return this._flattenedEditors;
235
+ }
236
+ this._shouldReFlattenEditors = false;
237
+ const editors = ( new Map());
238
+ for (const [glob, value] of this._editors) {
239
+ const registeredEditors = [];
240
+ for (const editors of ( value.values())) {
241
+ let registeredEditor = undefined;
242
+ for (const editor of editors) {
243
+ if (!registeredEditor) {
244
+ registeredEditor = {
245
+ editorInfo: editor.editorInfo,
246
+ globPattern: editor.globPattern,
247
+ options: {},
248
+ editorFactoryObject: {}
249
+ };
250
+ }
251
+ registeredEditor.options = { ...registeredEditor.options, ...editor.options };
252
+ registeredEditor.editorFactoryObject = { ...registeredEditor.editorFactoryObject, ...editor.editorFactoryObject };
253
+ }
254
+ if (registeredEditor) {
255
+ registeredEditors.push(registeredEditor);
256
+ }
257
+ }
258
+ editors.set(glob, registeredEditors);
259
+ }
260
+ return editors;
261
+ }
262
+ get _registeredEditors() {
263
+ return flatten(Array.from(( this._flattenedEditors.values())));
264
+ }
265
+ updateUserAssociations(globPattern, editorID) {
266
+ const newAssociation = { viewType: editorID, filenamePattern: globPattern };
267
+ const currentAssociations = this.getAllUserAssociations();
268
+ const newSettingObject = Object.create(null);
269
+ for (const association of [...currentAssociations, newAssociation]) {
270
+ if (association.filenamePattern) {
271
+ newSettingObject[association.filenamePattern] = association.viewType;
272
+ }
273
+ }
274
+ this.configurationService.updateValue(editorsAssociationsSettingId, newSettingObject);
275
+ }
276
+ findMatchingEditors(resource) {
277
+ const userSettings = this.getAssociationsForResource(resource);
278
+ const matchingEditors = [];
279
+ for (const [key, editors] of this._flattenedEditors) {
280
+ for (const editor of editors) {
281
+ const foundInSettings = userSettings.find(setting => setting.viewType === editor.editorInfo.id);
282
+ if ((foundInSettings && editor.editorInfo.priority !== RegisteredEditorPriority.exclusive) || globMatchesResource(key, resource)) {
283
+ matchingEditors.push(editor);
284
+ }
285
+ }
286
+ }
287
+ return matchingEditors.sort((a, b) => {
288
+ if (priorityToRank(b.editorInfo.priority) === priorityToRank(a.editorInfo.priority) && typeof b.globPattern === 'string' && typeof a.globPattern === 'string') {
289
+ return b.globPattern.length - a.globPattern.length;
290
+ }
291
+ return priorityToRank(b.editorInfo.priority) - priorityToRank(a.editorInfo.priority);
292
+ });
293
+ }
294
+ getEditors(resource) {
295
+ this._flattenedEditors = this._flattenEditorsMap();
296
+ if (URI.isUri(resource)) {
297
+ const editors = this.findMatchingEditors(resource);
298
+ if (editors.find(e => e.editorInfo.priority === RegisteredEditorPriority.exclusive)) {
299
+ return [];
300
+ }
301
+ return ( editors.map(editor => editor.editorInfo));
302
+ }
303
+ return distinct(( this._registeredEditors.map(editor => editor.editorInfo)), editor => editor.id);
304
+ }
305
+ getEditor(resource, editorId) {
306
+ const findMatchingEditor = (editors, viewType) => {
307
+ return editors.find((editor) => {
308
+ if (editor.options && editor.options.canSupportResource !== undefined) {
309
+ return editor.editorInfo.id === viewType && editor.options.canSupportResource(resource);
310
+ }
311
+ return editor.editorInfo.id === viewType;
312
+ });
313
+ };
314
+ if (editorId && editorId !== EditorResolution.EXCLUSIVE_ONLY) {
315
+ const registeredEditors = this._registeredEditors;
316
+ return {
317
+ editor: findMatchingEditor(registeredEditors, editorId),
318
+ conflictingDefault: false
319
+ };
320
+ }
321
+ const editors = this.findMatchingEditors(resource);
322
+ const associationsFromSetting = this.getAssociationsForResource(resource);
323
+ const minPriority = editorId === EditorResolution.EXCLUSIVE_ONLY ? RegisteredEditorPriority.exclusive : RegisteredEditorPriority.builtin;
324
+ let possibleEditors = editors.filter(editor => priorityToRank(editor.editorInfo.priority) >= priorityToRank(minPriority) && editor.editorInfo.id !== DEFAULT_EDITOR_ASSOCIATION.id);
325
+ if (possibleEditors.length === 0) {
326
+ return {
327
+ editor: associationsFromSetting[0] && minPriority !== RegisteredEditorPriority.exclusive ? findMatchingEditor(editors, associationsFromSetting[0].viewType) : undefined,
328
+ conflictingDefault: false
329
+ };
330
+ }
331
+ const selectedViewType = possibleEditors[0].editorInfo.priority === RegisteredEditorPriority.exclusive ?
332
+ possibleEditors[0].editorInfo.id :
333
+ associationsFromSetting[0]?.viewType || possibleEditors[0].editorInfo.id;
334
+ let conflictingDefault = false;
335
+ possibleEditors = possibleEditors.filter(editor => editor.editorInfo.priority !== RegisteredEditorPriority.exclusive);
336
+ if (associationsFromSetting.length === 0 && possibleEditors.length > 1) {
337
+ conflictingDefault = true;
338
+ }
339
+ return {
340
+ editor: findMatchingEditor(editors, selectedViewType),
341
+ conflictingDefault
342
+ };
343
+ }
344
+ async doResolveEditor(editor, group, selectedEditor) {
345
+ let options = editor.options;
346
+ const resource = EditorResourceAccessor.getCanonicalUri(editor, { supportSideBySide: SideBySideEditor.PRIMARY });
347
+ if (options && typeof options.activation === 'undefined') {
348
+ options = { ...options, activation: options.preserveFocus ? EditorActivation.RESTORE : undefined };
349
+ }
350
+ if (isResourceMergeEditorInput(editor)) {
351
+ if (!selectedEditor.editorFactoryObject.createMergeEditorInput) {
352
+ return;
353
+ }
354
+ const inputWithOptions = await selectedEditor.editorFactoryObject.createMergeEditorInput(editor, group);
355
+ return { editor: inputWithOptions.editor, options: inputWithOptions.options ?? options };
356
+ }
357
+ if (isResourceDiffEditorInput(editor)) {
358
+ if (!selectedEditor.editorFactoryObject.createDiffEditorInput) {
359
+ return;
360
+ }
361
+ const inputWithOptions = await selectedEditor.editorFactoryObject.createDiffEditorInput(editor, group);
362
+ return { editor: inputWithOptions.editor, options: inputWithOptions.options ?? options };
363
+ }
364
+ if (isResourceMultiDiffEditorInput(editor)) {
365
+ if (!selectedEditor.editorFactoryObject.createMultiDiffEditorInput) {
366
+ return;
367
+ }
368
+ const inputWithOptions = await selectedEditor.editorFactoryObject.createMultiDiffEditorInput(editor, group);
369
+ return { editor: inputWithOptions.editor, options: inputWithOptions.options ?? options };
370
+ }
371
+ if (isResourceSideBySideEditorInput(editor)) {
372
+ throw new Error(`Untyped side by side editor input not supported here.`);
373
+ }
374
+ if (isUntitledResourceEditorInput(editor)) {
375
+ if (!selectedEditor.editorFactoryObject.createUntitledEditorInput) {
376
+ return;
377
+ }
378
+ const inputWithOptions = await selectedEditor.editorFactoryObject.createUntitledEditorInput(editor, group);
379
+ return { editor: inputWithOptions.editor, options: inputWithOptions.options ?? options };
380
+ }
381
+ if (resource === undefined) {
382
+ throw new Error(`Undefined resource on non untitled editor input.`);
383
+ }
384
+ const singleEditorPerResource = typeof selectedEditor.options?.singlePerResource === 'function' ? selectedEditor.options.singlePerResource() : selectedEditor.options?.singlePerResource;
385
+ if (singleEditorPerResource) {
386
+ const existingEditors = this.findExistingEditorsForResource(resource, selectedEditor.editorInfo.id);
387
+ if (existingEditors.length) {
388
+ const editor = await this.moveExistingEditorForResource(existingEditors, group);
389
+ if (editor) {
390
+ return { editor, options };
391
+ }
392
+ else {
393
+ return;
394
+ }
395
+ }
396
+ }
397
+ if (!selectedEditor.editorFactoryObject.createEditorInput) {
398
+ return;
399
+ }
400
+ const inputWithOptions = await selectedEditor.editorFactoryObject.createEditorInput(editor, group);
401
+ options = inputWithOptions.options ?? options;
402
+ const input = inputWithOptions.editor;
403
+ return { editor: input, options };
404
+ }
405
+ async moveExistingEditorForResource(existingEditorsForResource, targetGroup) {
406
+ const editorToUse = existingEditorsForResource[0];
407
+ for (const { editor, group } of existingEditorsForResource) {
408
+ if (editor !== editorToUse.editor) {
409
+ const closed = await group.closeEditor(editor);
410
+ if (!closed) {
411
+ return;
412
+ }
413
+ }
414
+ }
415
+ if (targetGroup.id !== editorToUse.group.id) {
416
+ const moved = editorToUse.group.moveEditor(editorToUse.editor, targetGroup);
417
+ if (!moved) {
418
+ return;
419
+ }
420
+ }
421
+ return editorToUse.editor;
422
+ }
423
+ findExistingEditorsForResource(resource, editorId) {
424
+ const out = [];
425
+ const orderedGroups = distinct([
426
+ ...this.editorGroupService.groups,
427
+ ]);
428
+ for (const group of orderedGroups) {
429
+ for (const editor of group.editors) {
430
+ if (isEqual(editor.resource, resource) && editor.editorId === editorId) {
431
+ out.push({ editor, group });
432
+ }
433
+ }
434
+ }
435
+ return out;
436
+ }
437
+ async doHandleConflictingDefaults(resource, editorName, untypedInput, currentEditor, group) {
438
+ const editors = this.findMatchingEditors(resource);
439
+ const storedChoices = JSON.parse(this.storageService.get(EditorResolverService_1.conflictingDefaultsStorageID, 0 , '{}'));
440
+ const globForResource = `*${extname(resource)}`;
441
+ const writeCurrentEditorsToStorage = () => {
442
+ storedChoices[globForResource] = [];
443
+ editors.forEach(editor => storedChoices[globForResource].push(editor.editorInfo.id));
444
+ this.storageService.store(EditorResolverService_1.conflictingDefaultsStorageID, JSON.stringify(storedChoices), 0 , 1 );
445
+ };
446
+ if (storedChoices[globForResource] && storedChoices[globForResource].find(editorID => editorID === currentEditor.editorId)) {
447
+ return;
448
+ }
449
+ const handle = this.notificationService.prompt(Severity$1.Warning, ( localizeWithPath(
450
+ 'vs/workbench/services/editor/browser/editorResolverService',
451
+ 'editorResolver.conflictingDefaults',
452
+ 'There are multiple default editors available for the resource.'
453
+ )), [{
454
+ label: ( localizeWithPath(
455
+ 'vs/workbench/services/editor/browser/editorResolverService',
456
+ 'editorResolver.configureDefault',
457
+ 'Configure Default'
458
+ )),
459
+ run: async () => {
460
+ const picked = await this.doPickEditor(untypedInput, true);
461
+ if (!picked) {
462
+ return;
463
+ }
464
+ untypedInput.options = picked;
465
+ const replacementEditor = await this.resolveEditor(untypedInput, group);
466
+ if (replacementEditor === 1 || replacementEditor === 2 ) {
467
+ return;
468
+ }
469
+ group.replaceEditors([
470
+ {
471
+ editor: currentEditor,
472
+ replacement: replacementEditor.editor,
473
+ options: replacementEditor.options ?? picked,
474
+ }
475
+ ]);
476
+ }
477
+ },
478
+ {
479
+ label: ( localizeWithPath(
480
+ 'vs/workbench/services/editor/browser/editorResolverService',
481
+ 'editorResolver.keepDefault',
482
+ 'Keep {0}',
483
+ editorName
484
+ )),
485
+ run: writeCurrentEditorsToStorage
486
+ }
487
+ ]);
488
+ const onCloseListener = handle.onDidClose(() => {
489
+ writeCurrentEditorsToStorage();
490
+ onCloseListener.dispose();
491
+ });
492
+ }
493
+ mapEditorsToQuickPickEntry(resource, showDefaultPicker) {
494
+ const currentEditor = firstOrDefault(this.editorGroupService.activeGroup.findEditors(resource));
495
+ let registeredEditors = resource.scheme === Schemas.untitled ? this._registeredEditors.filter(e => e.editorInfo.priority !== RegisteredEditorPriority.exclusive) : this.findMatchingEditors(resource);
496
+ registeredEditors = distinct(registeredEditors, c => c.editorInfo.id);
497
+ const defaultSetting = this.getAssociationsForResource(resource)[0]?.viewType;
498
+ registeredEditors = registeredEditors.sort((a, b) => {
499
+ if (a.editorInfo.id === DEFAULT_EDITOR_ASSOCIATION.id) {
500
+ return -1;
501
+ }
502
+ else if (b.editorInfo.id === DEFAULT_EDITOR_ASSOCIATION.id) {
503
+ return 1;
504
+ }
505
+ else {
506
+ return priorityToRank(b.editorInfo.priority) - priorityToRank(a.editorInfo.priority);
507
+ }
508
+ });
509
+ const quickPickEntries = [];
510
+ const currentlyActiveLabel = ( localizeWithPath(
511
+ 'vs/workbench/services/editor/browser/editorResolverService',
512
+ 'promptOpenWith.currentlyActive',
513
+ "Active"
514
+ ));
515
+ const currentDefaultLabel = ( localizeWithPath(
516
+ 'vs/workbench/services/editor/browser/editorResolverService',
517
+ 'promptOpenWith.currentDefault',
518
+ "Default"
519
+ ));
520
+ const currentDefaultAndActiveLabel = ( localizeWithPath(
521
+ 'vs/workbench/services/editor/browser/editorResolverService',
522
+ 'promptOpenWith.currentDefaultAndActive',
523
+ "Active and Default"
524
+ ));
525
+ let defaultViewType = defaultSetting;
526
+ if (!defaultViewType && registeredEditors.length > 2 && registeredEditors[1]?.editorInfo.priority !== RegisteredEditorPriority.option) {
527
+ defaultViewType = registeredEditors[1]?.editorInfo.id;
528
+ }
529
+ if (!defaultViewType) {
530
+ defaultViewType = DEFAULT_EDITOR_ASSOCIATION.id;
531
+ }
532
+ registeredEditors.forEach(editor => {
533
+ const currentViewType = currentEditor?.editorId ?? DEFAULT_EDITOR_ASSOCIATION.id;
534
+ const isActive = currentEditor ? editor.editorInfo.id === currentViewType : false;
535
+ const isDefault = editor.editorInfo.id === defaultViewType;
536
+ const quickPickEntry = {
537
+ id: editor.editorInfo.id,
538
+ label: editor.editorInfo.label,
539
+ description: isActive && isDefault ? currentDefaultAndActiveLabel : isActive ? currentlyActiveLabel : isDefault ? currentDefaultLabel : undefined,
540
+ detail: editor.editorInfo.detail ?? editor.editorInfo.priority,
541
+ };
542
+ quickPickEntries.push(quickPickEntry);
543
+ });
544
+ if (!showDefaultPicker && extname(resource) !== '') {
545
+ const separator = { type: 'separator' };
546
+ quickPickEntries.push(separator);
547
+ const configureDefaultEntry = {
548
+ id: EditorResolverService_1.configureDefaultID,
549
+ label: ( localizeWithPath(
550
+ 'vs/workbench/services/editor/browser/editorResolverService',
551
+ 'promptOpenWith.configureDefault',
552
+ "Configure default editor for '{0}'...",
553
+ `*${extname(resource)}`
554
+ )),
555
+ };
556
+ quickPickEntries.push(configureDefaultEntry);
557
+ }
558
+ return quickPickEntries;
559
+ }
560
+ async doPickEditor(editor, showDefaultPicker) {
561
+ let resource = EditorResourceAccessor.getOriginalUri(editor, { supportSideBySide: SideBySideEditor.PRIMARY });
562
+ if (resource === undefined) {
563
+ resource = ( URI.from({ scheme: Schemas.untitled }));
564
+ }
565
+ const editorPicks = this.mapEditorsToQuickPickEntry(resource, showDefaultPicker);
566
+ const editorPicker = this.quickInputService.createQuickPick();
567
+ const placeHolderMessage = showDefaultPicker ?
568
+ ( localizeWithPath(
569
+ 'vs/workbench/services/editor/browser/editorResolverService',
570
+ 'promptOpenWith.updateDefaultPlaceHolder',
571
+ "Select new default editor for '{0}'",
572
+ `*${extname(resource)}`
573
+ )) :
574
+ ( localizeWithPath(
575
+ 'vs/workbench/services/editor/browser/editorResolverService',
576
+ 'promptOpenWith.placeHolder',
577
+ "Select editor for '{0}'",
578
+ basename(resource)
579
+ ));
580
+ editorPicker.placeholder = placeHolderMessage;
581
+ editorPicker.canAcceptInBackground = true;
582
+ editorPicker.items = editorPicks;
583
+ const firstItem = editorPicker.items.find(item => item.type === 'item');
584
+ if (firstItem) {
585
+ editorPicker.selectedItems = [firstItem];
586
+ }
587
+ const picked = await ( new Promise(resolve => {
588
+ editorPicker.onDidAccept(e => {
589
+ let result = undefined;
590
+ if (editorPicker.selectedItems.length === 1) {
591
+ result = {
592
+ item: editorPicker.selectedItems[0],
593
+ keyMods: editorPicker.keyMods,
594
+ openInBackground: e.inBackground
595
+ };
596
+ }
597
+ if (resource && showDefaultPicker && result?.item.id) {
598
+ this.updateUserAssociations(`*${extname(resource)}`, result.item.id);
599
+ }
600
+ resolve(result);
601
+ });
602
+ editorPicker.onDidHide(() => resolve(undefined));
603
+ editorPicker.onDidTriggerItemButton(e => {
604
+ resolve({ item: e.item, openInBackground: false });
605
+ if (resource && e.item && e.item.id) {
606
+ this.updateUserAssociations(`*${extname(resource)}`, e.item.id);
607
+ }
608
+ });
609
+ editorPicker.show();
610
+ }));
611
+ editorPicker.dispose();
612
+ if (picked) {
613
+ if (picked.item.id === EditorResolverService_1.configureDefaultID) {
614
+ return this.doPickEditor(editor, true);
615
+ }
616
+ const targetOptions = {
617
+ ...editor.options,
618
+ override: picked.item.id,
619
+ preserveFocus: picked.openInBackground || editor.options?.preserveFocus,
620
+ };
621
+ return targetOptions;
622
+ }
623
+ return undefined;
624
+ }
625
+ sendEditorResolutionTelemetry(chosenInput) {
626
+ if (chosenInput.editorId) {
627
+ this.telemetryService.publicLog2('override.viewType', { viewType: chosenInput.editorId });
628
+ }
629
+ }
630
+ cacheEditors() {
631
+ const cacheStorage = ( new Set());
632
+ for (const [globPattern, contribPoint] of this._flattenedEditors) {
633
+ const nonOptional = !!contribPoint.find(c => c.editorInfo.priority !== RegisteredEditorPriority.option && c.editorInfo.id !== DEFAULT_EDITOR_ASSOCIATION.id);
634
+ if (!nonOptional) {
635
+ continue;
636
+ }
637
+ if (isRelativePattern(globPattern)) {
638
+ cacheStorage.add(`${globPattern.pattern}`);
639
+ }
640
+ else {
641
+ cacheStorage.add(globPattern);
642
+ }
643
+ }
644
+ const userAssociations = this.getAllUserAssociations();
645
+ for (const association of userAssociations) {
646
+ if (association.filenamePattern) {
647
+ cacheStorage.add(association.filenamePattern);
648
+ }
649
+ }
650
+ this.storageService.store(EditorResolverService_1.cacheStorageID, JSON.stringify(Array.from(cacheStorage)), 0 , 1 );
651
+ }
652
+ resourceMatchesCache(resource) {
653
+ if (!this.cache) {
654
+ return false;
655
+ }
656
+ for (const cacheEntry of this.cache) {
657
+ if (globMatchesResource(cacheEntry, resource)) {
658
+ return true;
659
+ }
660
+ }
661
+ return false;
662
+ }
663
+ };
664
+ EditorResolverService = EditorResolverService_1 = ( __decorate([
665
+ ( __param(0, IEditorGroupsService)),
666
+ ( __param(1, IInstantiationService)),
667
+ ( __param(2, IConfigurationService)),
668
+ ( __param(3, IQuickInputService)),
669
+ ( __param(4, INotificationService)),
670
+ ( __param(5, ITelemetryService)),
671
+ ( __param(6, IStorageService)),
672
+ ( __param(7, IExtensionService)),
673
+ ( __param(8, ILogService))
674
+ ], EditorResolverService));
675
+
676
+ export { EditorResolverService };