@codingame/monaco-vscode-api 2.1.4 → 2.2.0-next.2

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