@codingame/monaco-vscode-api 2.1.4 → 2.2.0-next.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 (190) hide show
  1. package/README.md +2 -0
  2. package/contributions.js +1 -0
  3. package/extensions.d.ts +6 -3
  4. package/extensions.js +18 -7
  5. package/lifecycle.js +11 -3
  6. package/missing-services.js +55 -10
  7. package/monaco.js +7 -3
  8. package/package.json +8 -8
  9. package/service-override/tools/views.d.ts +98 -0
  10. package/service-override/tools/views.js +249 -0
  11. package/services.d.ts +4 -2
  12. package/services.js +11 -9
  13. package/vscode/src/vs/base/browser/deviceAccess.js +60 -0
  14. package/vscode/src/vs/base/browser/dom.js +18 -1
  15. package/vscode/src/vs/base/browser/ui/centered/centeredViewLayout.js +178 -0
  16. package/vscode/src/vs/base/browser/ui/grid/grid.js +492 -0
  17. package/vscode/src/vs/base/browser/ui/grid/gridview.css.js +4 -0
  18. package/vscode/src/vs/base/browser/ui/grid/gridview.d.ts +1 -0
  19. package/vscode/src/vs/base/browser/ui/grid/gridview.js +1109 -0
  20. package/vscode/src/vs/base/browser/ui/sash/sash.js +9 -1
  21. package/vscode/src/vs/base/browser/ui/splitview/splitview.d.ts +348 -1
  22. package/vscode/src/vs/base/common/async.js +46 -2
  23. package/vscode/src/vs/base/common/codicons.d.ts +579 -0
  24. package/vscode/src/vs/base/common/event.js +11 -2
  25. package/vscode/src/vs/base/common/keybindingParser.js +87 -0
  26. package/vscode/src/vs/base/common/network.js +1 -2
  27. package/vscode/src/vs/base/common/observableInternal/utils.js +1 -1
  28. package/vscode/src/vs/base/common/platform.js +2 -1
  29. package/vscode/src/vs/base/common/scrollable.d.ts +28 -0
  30. package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/colors.js +17 -0
  31. package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/diffEditorItemTemplate.js +214 -0
  32. package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/multiDiffEditorViewModel.js +84 -0
  33. package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/multiDiffEditorWidget.js +54 -0
  34. package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/multiDiffEditorWidgetImpl.js +324 -0
  35. package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/objectPool.js +46 -0
  36. package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/style.css.js +4 -0
  37. package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/utils.js +11 -0
  38. package/vscode/src/vs/platform/keyboardLayout/common/keyboardLayout.js +61 -1
  39. package/vscode/src/vs/platform/languagePacks/common/localizedStrings.js +10 -0
  40. package/vscode/src/vs/platform/log/browser/log.js +24 -0
  41. package/vscode/src/vs/platform/product/common/product.js +1 -2
  42. package/vscode/src/vs/platform/userDataSync/common/abstractSynchronizer.js +772 -0
  43. package/vscode/src/vs/platform/userDataSync/common/userDataSyncStoreService.js +551 -0
  44. package/vscode/src/vs/platform/webview/common/mimeTypes.js +22 -0
  45. package/vscode/src/vs/platform/webview/common/webviewPortMapping.js +62 -0
  46. package/vscode/src/vs/workbench/api/browser/viewsExtensionPoint.js +788 -0
  47. package/vscode/src/vs/workbench/browser/actions/listCommands.js +763 -0
  48. package/vscode/src/vs/workbench/browser/layout.d.ts +26 -0
  49. package/vscode/src/vs/workbench/browser/media/style.css.js +1 -1
  50. package/vscode/src/vs/workbench/browser/parts/activitybar/activitybarPart.js +610 -0
  51. package/vscode/src/vs/workbench/browser/parts/activitybar/media/activityaction.css.js +4 -0
  52. package/vscode/src/vs/workbench/browser/parts/activitybar/media/activitybarpart.css.js +4 -0
  53. package/vscode/src/vs/workbench/browser/parts/auxiliarybar/auxiliaryBarPart.js +148 -0
  54. package/vscode/src/vs/workbench/browser/parts/auxiliarybar/media/auxiliaryBarPart.css.js +4 -0
  55. package/vscode/src/vs/workbench/browser/parts/compositeBar.js +603 -0
  56. package/vscode/src/vs/workbench/browser/parts/compositePart.js +333 -0
  57. package/vscode/src/vs/workbench/browser/parts/editor/auxiliaryEditorPart.js +221 -0
  58. package/vscode/src/vs/workbench/browser/parts/editor/editor.contribution.js +1406 -0
  59. package/vscode/src/vs/workbench/browser/parts/editor/editorConfiguration.js +184 -0
  60. package/vscode/src/vs/workbench/browser/parts/editor/editorDropTarget.js +509 -0
  61. package/vscode/src/vs/workbench/browser/parts/editor/editorPane.d.ts +112 -0
  62. package/vscode/src/vs/workbench/browser/parts/editor/editorPart.js +1018 -0
  63. package/vscode/src/vs/workbench/browser/parts/editor/editorParts.js +389 -0
  64. package/vscode/src/vs/workbench/browser/parts/editor/media/editordroptarget.css.js +4 -0
  65. package/vscode/src/vs/workbench/browser/parts/media/compositepart.css.js +4 -0
  66. package/vscode/src/vs/workbench/browser/parts/media/paneCompositePart.css.js +4 -0
  67. package/vscode/src/vs/workbench/browser/parts/notifications/media/notificationsActions.css.js +4 -0
  68. package/vscode/src/vs/workbench/browser/parts/notifications/media/notificationsCenter.css.js +4 -0
  69. package/vscode/src/vs/workbench/browser/parts/notifications/media/notificationsList.css.js +4 -0
  70. package/vscode/src/vs/workbench/browser/parts/notifications/media/notificationsToasts.css.js +4 -0
  71. package/vscode/src/vs/workbench/browser/parts/notifications/notificationsActions.js +213 -0
  72. package/vscode/src/vs/workbench/browser/parts/notifications/notificationsAlerts.js +73 -0
  73. package/vscode/src/vs/workbench/browser/parts/notifications/notificationsCenter.js +307 -0
  74. package/vscode/src/vs/workbench/browser/parts/notifications/notificationsList.js +226 -0
  75. package/vscode/src/vs/workbench/browser/parts/notifications/notificationsStatus.js +218 -0
  76. package/vscode/src/vs/workbench/browser/parts/notifications/notificationsToasts.js +433 -0
  77. package/vscode/src/vs/workbench/browser/parts/notifications/notificationsViewer.js +436 -0
  78. package/vscode/src/vs/workbench/browser/parts/paneCompositeBar.js +643 -0
  79. package/vscode/src/vs/workbench/browser/parts/paneCompositePart.js +377 -0
  80. package/vscode/src/vs/workbench/browser/parts/paneCompositePartService.js +66 -0
  81. package/vscode/src/vs/workbench/browser/parts/panel/panelPart.js +144 -0
  82. package/vscode/src/vs/workbench/browser/parts/sidebar/media/sidebarpart.css.js +4 -0
  83. package/vscode/src/vs/workbench/browser/parts/sidebar/sidebarPart.js +220 -0
  84. package/vscode/src/vs/workbench/browser/window.js +239 -5
  85. package/vscode/src/vs/workbench/common/configuration.js +11 -1
  86. package/vscode/src/vs/workbench/common/theme.js +3 -3
  87. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchy.contribution.js +298 -0
  88. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyPeek.js +363 -0
  89. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyTree.js +133 -0
  90. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/media/callHierarchy.css.js +4 -0
  91. package/vscode/src/vs/workbench/contrib/comments/browser/commentGlyphWidget.js +90 -0
  92. package/vscode/src/vs/workbench/contrib/comments/browser/commentMenus.js +43 -0
  93. package/vscode/src/vs/workbench/contrib/comments/browser/commentService.js +317 -2
  94. package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadRangeDecorator.js +107 -0
  95. package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.js +395 -0
  96. package/vscode/src/vs/workbench/contrib/comments/browser/comments.js +3 -0
  97. package/vscode/src/vs/workbench/contrib/comments/browser/commentsController.js +1277 -0
  98. package/vscode/src/vs/workbench/contrib/comments/browser/commentsFilterOptions.js +17 -0
  99. package/vscode/src/vs/workbench/contrib/comments/browser/commentsModel.js +123 -0
  100. package/vscode/src/vs/workbench/contrib/comments/browser/commentsTreeViewer.js +342 -0
  101. package/vscode/src/vs/workbench/contrib/comments/browser/commentsView.js +451 -0
  102. package/vscode/src/vs/workbench/contrib/comments/browser/commentsViewActions.js +176 -0
  103. package/vscode/src/vs/workbench/contrib/comments/browser/media/panel.css.js +4 -0
  104. package/vscode/src/vs/workbench/contrib/comments/common/commentModel.js +35 -0
  105. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditor.contribution.js +16 -0
  106. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.js +143 -0
  107. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditors.js +212 -0
  108. package/vscode/src/vs/workbench/contrib/customEditor/browser/media/customEditor.css.js +4 -0
  109. package/vscode/src/vs/workbench/contrib/customEditor/common/contributedCustomEditors.js +76 -0
  110. package/vscode/src/vs/workbench/contrib/customEditor/common/customEditorModelManager.js +61 -0
  111. package/vscode/src/vs/workbench/contrib/customEditor/common/extensionPoint.js +117 -0
  112. package/vscode/src/vs/workbench/contrib/editSessions/common/editSessions.js +62 -0
  113. package/vscode/src/vs/workbench/contrib/externalUriOpener/common/externalUriOpener.contribution.js +5 -0
  114. package/vscode/src/vs/workbench/contrib/files/browser/editors/binaryFileEditor.js +77 -0
  115. package/vscode/src/vs/workbench/contrib/files/browser/editors/fileEditorHandler.js +72 -0
  116. package/vscode/src/vs/workbench/contrib/files/browser/editors/textFileEditor.js +254 -0
  117. package/vscode/src/vs/workbench/contrib/files/browser/editors/textFileEditorTracker.js +97 -0
  118. package/vscode/src/vs/workbench/contrib/files/browser/editors/textFileSaveErrorHandler.js +442 -0
  119. package/vscode/src/vs/workbench/contrib/files/browser/explorerService.js +430 -0
  120. package/vscode/src/vs/workbench/contrib/files/browser/fileActions.contribution.js +784 -0
  121. package/vscode/src/vs/workbench/contrib/files/browser/fileCommands.js +487 -0
  122. package/vscode/src/vs/workbench/contrib/files/browser/files.contribution.js +521 -0
  123. package/vscode/src/vs/workbench/contrib/files/browser/workspaceWatcher.js +150 -0
  124. package/vscode/src/vs/workbench/contrib/files/common/dirtyFilesIndicator.js +61 -0
  125. package/vscode/src/vs/workbench/contrib/interactive/browser/interactiveDocumentService.js +25 -1
  126. package/vscode/src/vs/workbench/contrib/interactive/browser/interactiveEditorInput.js +178 -0
  127. package/vscode/src/vs/workbench/contrib/interactive/browser/interactiveHistoryService.js +49 -0
  128. package/vscode/src/vs/workbench/contrib/languageStatus/browser/languageStatus.contribution.js +408 -0
  129. package/vscode/src/vs/workbench/contrib/languageStatus/browser/media/languageStatus.css.js +4 -0
  130. package/vscode/src/vs/workbench/contrib/limitIndicator/browser/limitIndicator.contribution.js +145 -0
  131. package/vscode/src/vs/workbench/contrib/mappedEdits/common/mappedEdits.contribution.js +22 -0
  132. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/commands.js +691 -0
  133. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/devCommands.js +238 -0
  134. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditor.contribution.js +76 -0
  135. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorSerializer.js +40 -0
  136. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/colors.js +69 -0
  137. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/conflictActions.js +346 -0
  138. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editorGutter.js +96 -0
  139. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/baseCodeEditorView.js +144 -0
  140. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/codeEditorView.js +103 -0
  141. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/inputCodeEditorView.js +399 -0
  142. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/resultCodeEditorView.js +195 -0
  143. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/fixedZoneWidget.js +39 -0
  144. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/lineAlignment.js +126 -0
  145. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/media/mergeEditor.css.js +4 -0
  146. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/mergeEditor.js +611 -0
  147. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/scrollSynchronizer.js +156 -0
  148. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/viewModel.js +262 -0
  149. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/viewZones.js +171 -0
  150. package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/multiDiffSourceResolverService.js +41 -0
  151. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/executionStatusBarItemController.js +317 -0
  152. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/notebookVisibleCellObserver.js +56 -0
  153. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget.js +315 -0
  154. package/vscode/src/vs/workbench/contrib/preferences/browser/keyboardLayoutPicker.js +193 -0
  155. package/vscode/src/vs/workbench/contrib/preferences/common/preferences.js +2 -1
  156. package/vscode/src/vs/workbench/contrib/sash/browser/sash.contribution.js +37 -0
  157. package/vscode/src/vs/workbench/contrib/sash/browser/sash.js +39 -0
  158. package/vscode/src/vs/workbench/contrib/speech/common/speechService.js +138 -2
  159. package/vscode/src/vs/workbench/contrib/tags/browser/workspaceTagsService.js +12 -0
  160. package/vscode/src/vs/workbench/contrib/tags/common/workspaceTags.js +3 -0
  161. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/media/typeHierarchy.css.js +4 -0
  162. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchy.contribution.js +281 -0
  163. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyPeek.js +358 -0
  164. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyTree.js +131 -0
  165. package/vscode/src/vs/workbench/contrib/update/common/update.js +2 -0
  166. package/vscode/src/vs/workbench/contrib/webview/browser/overlayWebview.js +288 -0
  167. package/vscode/src/vs/workbench/contrib/webview/browser/resourceLoading.js +94 -0
  168. package/vscode/src/vs/workbench/contrib/webview/browser/themeing.js +86 -0
  169. package/vscode/src/vs/workbench/contrib/webview/browser/webview.contribution.js +77 -0
  170. package/vscode/src/vs/workbench/contrib/webview/browser/webviewElement.js +646 -0
  171. package/vscode/src/vs/workbench/contrib/webview/browser/webviewFindWidget.js +63 -0
  172. package/vscode/src/vs/workbench/contrib/webview/browser/webviewService.js +57 -0
  173. package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewCommands.js +140 -0
  174. package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewEditorInputSerializer.js +119 -0
  175. package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewPanel.contribution.js +67 -0
  176. package/vscode/src/vs/workbench/contrib/webviewView/browser/webviewViewPane.js +233 -0
  177. package/vscode/src/vs/workbench/services/activity/browser/activityService.js +143 -0
  178. package/vscode/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.js +0 -3
  179. package/vscode/src/vs/workbench/services/driver/browser/driver.js +184 -0
  180. package/vscode/src/vs/workbench/services/editor/browser/editorResolverService.js +668 -0
  181. package/vscode/src/vs/workbench/services/history/browser/historyService.js +1482 -0
  182. package/vscode/src/vs/workbench/services/layout/browser/layoutService.js +17 -1
  183. package/vscode/src/vs/workbench/services/lifecycle/common/lifecycle.js +8 -1
  184. package/vscode/src/vs/workbench/services/progress/browser/media/progressService.css.js +4 -0
  185. package/vscode/src/vs/workbench/services/progress/browser/progressService.js +521 -0
  186. package/vscode/src/vs/workbench/services/textMate/common/TMGrammars.js +102 -0
  187. package/vscode/src/vs/workbench/services/themes/common/tokenClassificationExtensionPoint.js +296 -0
  188. package/vscode/src/vs/workbench/services/untitled/common/untitledTextEditorHandler.js +99 -0
  189. package/vscode/src/vs/workbench/services/views/browser/viewDescriptorService.js +711 -0
  190. package/vscode/src/vs/workbench/services/views/common/viewContainerModel.js +596 -0
@@ -0,0 +1,1018 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { IThemeService } from '../../../../platform/theme/common/themeService.js';
3
+ import { Part } from '../../part.js';
4
+ import { getWindow, getActiveElement, isAncestorOfActiveElement, addDisposableGenericMouseDownListener, EventHelper, Dimension, $ } from '../../../../base/browser/dom.js';
5
+ import { Emitter, Relay, Event } from '../../../../base/common/event.js';
6
+ import { contrastBorder, editorBackground } from '../../../../platform/theme/common/colorRegistry.js';
7
+ import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
8
+ import { isGridBranchNode, createSerializedGrid, Sizing, SerializableGrid } from '../../../../base/browser/ui/grid/grid.js';
9
+ import { EDITOR_GROUP_BORDER, EDITOR_PANE_BACKGROUND } from '../../../common/theme.js';
10
+ import { coalesce, distinct } from '../../../../base/common/arrays.js';
11
+ import { getEditorPartOptions, impactsEditorPartOptions } from './editor.js';
12
+ import { EditorGroupView } from './editorGroupView.js';
13
+ import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
14
+ import { DisposableStore, toDisposable, dispose } from '../../../../base/common/lifecycle.js';
15
+ import { IStorageService } from '../../../../platform/storage/common/storage.js';
16
+ import { isSerializedEditorGroupModel } from '../../../common/editor/editorGroupModel.js';
17
+ import { EditorDropTarget } from './editorDropTarget.js';
18
+ import { Color } from '../../../../base/common/color.js';
19
+ import { CenteredViewLayout } from '../../../../base/browser/ui/centered/centeredViewLayout.js';
20
+ import { onUnexpectedError } from '../../../../base/common/errors.js';
21
+ import { IWorkbenchLayoutService } from '../../../services/layout/browser/layoutService.js';
22
+ import { assertType, assertIsDefined } from '../../../../base/common/types.js';
23
+ import { CompositeDragAndDropObserver } from '../../dnd.js';
24
+ import { DeferredPromise, Promises } from '../../../../base/common/async.js';
25
+ import { findGroup } from '../../../services/editor/common/editorGroupFinder.js';
26
+ import { SIDE_GROUP } from '../../../services/editor/common/editorService.js';
27
+ import { IHostService } from '../../../services/host/browser/host.js';
28
+ import { IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
29
+ import { ServiceCollection } from '../../../../platform/instantiation/common/serviceCollection.js';
30
+ import { IsAuxiliaryEditorPartContext, EditorPartMultipleEditorGroupsContext, EditorPartMaximizedEditorGroupContext } from '../../../common/contextkeys.js';
31
+ import { mainWindow } from '../../../../base/browser/window.js';
32
+ import { orthogonal } from '../../../../base/browser/ui/grid/gridview.js';
33
+ var EditorPart_1;
34
+ class GridWidgetView {
35
+ constructor() {
36
+ this.element = $('.grid-view-container');
37
+ this._onDidChange = ( new Relay());
38
+ this.onDidChange = this._onDidChange.event;
39
+ }
40
+ get minimumWidth() { return this.gridWidget ? this.gridWidget.minimumWidth : 0; }
41
+ get maximumWidth() { return this.gridWidget ? this.gridWidget.maximumWidth : Number.POSITIVE_INFINITY; }
42
+ get minimumHeight() { return this.gridWidget ? this.gridWidget.minimumHeight : 0; }
43
+ get maximumHeight() { return this.gridWidget ? this.gridWidget.maximumHeight : Number.POSITIVE_INFINITY; }
44
+ get gridWidget() {
45
+ return this._gridWidget;
46
+ }
47
+ set gridWidget(grid) {
48
+ this.element.innerText = '';
49
+ if (grid) {
50
+ this.element.appendChild(grid.element);
51
+ this._onDidChange.input = grid.onDidChange;
52
+ }
53
+ else {
54
+ this._onDidChange.input = Event.None;
55
+ }
56
+ this._gridWidget = grid;
57
+ }
58
+ layout(width, height, top, left) {
59
+ this.gridWidget?.layout(width, height, top, left);
60
+ }
61
+ dispose() {
62
+ this._onDidChange.dispose();
63
+ }
64
+ }
65
+ let EditorPart = class EditorPart extends Part {
66
+ static { EditorPart_1 = this; }
67
+ static { this.EDITOR_PART_UI_STATE_STORAGE_KEY = 'editorpart.state'; }
68
+ static { this.EDITOR_PART_CENTERED_VIEW_STORAGE_KEY = 'editorpart.centeredview'; }
69
+ constructor(editorPartsView, id, groupsLabel, windowId, instantiationService, themeService, configurationService, storageService, layoutService, hostService, contextKeyService) {
70
+ super(id, { hasTitle: false }, themeService, storageService, layoutService);
71
+ this.editorPartsView = editorPartsView;
72
+ this.groupsLabel = groupsLabel;
73
+ this.windowId = windowId;
74
+ this.instantiationService = instantiationService;
75
+ this.configurationService = configurationService;
76
+ this.hostService = hostService;
77
+ this.contextKeyService = contextKeyService;
78
+ this._onDidFocus = this._register(( new Emitter()));
79
+ this.onDidFocus = this._onDidFocus.event;
80
+ this._onDidLayout = this._register(( new Emitter()));
81
+ this.onDidLayout = this._onDidLayout.event;
82
+ this._onDidChangeActiveGroup = this._register(( new Emitter()));
83
+ this.onDidChangeActiveGroup = this._onDidChangeActiveGroup.event;
84
+ this._onDidChangeGroupIndex = this._register(( new Emitter()));
85
+ this.onDidChangeGroupIndex = this._onDidChangeGroupIndex.event;
86
+ this._onDidChangeGroupLabel = this._register(( new Emitter()));
87
+ this.onDidChangeGroupLabel = this._onDidChangeGroupLabel.event;
88
+ this._onDidChangeGroupLocked = this._register(( new Emitter()));
89
+ this.onDidChangeGroupLocked = this._onDidChangeGroupLocked.event;
90
+ this._onDidChangeGroupMaximized = this._register(( new Emitter()));
91
+ this.onDidChangeGroupMaximized = this._onDidChangeGroupMaximized.event;
92
+ this._onDidActivateGroup = this._register(( new Emitter()));
93
+ this.onDidActivateGroup = this._onDidActivateGroup.event;
94
+ this._onDidAddGroup = this._register(( new Emitter()));
95
+ this.onDidAddGroup = this._onDidAddGroup.event;
96
+ this._onDidRemoveGroup = this._register(( new Emitter()));
97
+ this.onDidRemoveGroup = this._onDidRemoveGroup.event;
98
+ this._onDidMoveGroup = this._register(( new Emitter()));
99
+ this.onDidMoveGroup = this._onDidMoveGroup.event;
100
+ this.onDidSetGridWidget = this._register(( new Emitter()));
101
+ this._onDidChangeSizeConstraints = this._register(( new Relay()));
102
+ this.onDidChangeSizeConstraints = Event.any(this.onDidSetGridWidget.event, this._onDidChangeSizeConstraints.event);
103
+ this._onDidScroll = this._register(( new Relay()));
104
+ this.onDidScroll = Event.any(this.onDidSetGridWidget.event, this._onDidScroll.event);
105
+ this._onDidChangeEditorPartOptions = this._register(( new Emitter()));
106
+ this.onDidChangeEditorPartOptions = this._onDidChangeEditorPartOptions.event;
107
+ this.workspaceMemento = this.getMemento(1 , 0 );
108
+ this.profileMemento = this.getMemento(0 , 1 );
109
+ this.groupViews = ( new Map());
110
+ this.mostRecentActiveGroups = [];
111
+ this.gridWidgetDisposables = this._register(( new DisposableStore()));
112
+ this.gridWidgetView = this._register(( new GridWidgetView()));
113
+ this.enforcedPartOptions = [];
114
+ this._partOptions = getEditorPartOptions(this.configurationService, this.themeService);
115
+ this.top = 0;
116
+ this.left = 0;
117
+ this.sideGroup = {
118
+ openEditor: (editor, options) => {
119
+ const [group] = this.scopedInstantiationService.invokeFunction(accessor => findGroup(accessor, { editor, options }, SIDE_GROUP));
120
+ return group.openEditor(editor, options);
121
+ }
122
+ };
123
+ this._isReady = false;
124
+ this.whenReadyPromise = ( new DeferredPromise());
125
+ this.whenReady = this.whenReadyPromise.p;
126
+ this.whenRestoredPromise = ( new DeferredPromise());
127
+ this.whenRestored = this.whenRestoredPromise.p;
128
+ this._willRestoreState = false;
129
+ this.priority = 2 ;
130
+ this.registerListeners();
131
+ }
132
+ registerListeners() {
133
+ this._register(this.configurationService.onDidChangeConfiguration(e => this.onConfigurationUpdated(e)));
134
+ this._register(this.themeService.onDidFileIconThemeChange(() => this.handleChangedPartOptions()));
135
+ this._register(this.onDidChangeMementoValue(1 , this._store)(e => this.onDidChangeMementoState(e)));
136
+ }
137
+ onConfigurationUpdated(event) {
138
+ if (impactsEditorPartOptions(event)) {
139
+ this.handleChangedPartOptions();
140
+ }
141
+ }
142
+ handleChangedPartOptions() {
143
+ const oldPartOptions = this._partOptions;
144
+ const newPartOptions = getEditorPartOptions(this.configurationService, this.themeService);
145
+ for (const enforcedPartOptions of this.enforcedPartOptions) {
146
+ Object.assign(newPartOptions, enforcedPartOptions);
147
+ }
148
+ this._partOptions = newPartOptions;
149
+ this._onDidChangeEditorPartOptions.fire({ oldPartOptions, newPartOptions });
150
+ }
151
+ get partOptions() { return this._partOptions; }
152
+ enforcePartOptions(options) {
153
+ this.enforcedPartOptions.push(options);
154
+ this.handleChangedPartOptions();
155
+ return toDisposable(() => {
156
+ this.enforcedPartOptions.splice(this.enforcedPartOptions.indexOf(options), 1);
157
+ this.handleChangedPartOptions();
158
+ });
159
+ }
160
+ get contentDimension() { return this._contentDimension; }
161
+ get activeGroup() {
162
+ return this._activeGroup;
163
+ }
164
+ get groups() {
165
+ return Array.from(( this.groupViews.values()));
166
+ }
167
+ get count() {
168
+ return this.groupViews.size;
169
+ }
170
+ get orientation() {
171
+ return ((this.gridWidget && this.gridWidget.orientation === 0) ) ? 1 : 0 ;
172
+ }
173
+ get isReady() { return this._isReady; }
174
+ get hasRestorableState() {
175
+ return !!this.workspaceMemento[EditorPart_1.EDITOR_PART_UI_STATE_STORAGE_KEY];
176
+ }
177
+ get willRestoreState() { return this._willRestoreState; }
178
+ getGroups(order = 0 ) {
179
+ switch (order) {
180
+ case 0 :
181
+ return this.groups;
182
+ case 1 : {
183
+ const mostRecentActive = coalesce(( this.mostRecentActiveGroups.map(groupId => this.getGroup(groupId))));
184
+ return distinct([...mostRecentActive, ...this.groups]);
185
+ }
186
+ case 2 : {
187
+ const views = [];
188
+ if (this.gridWidget) {
189
+ this.fillGridNodes(views, this.gridWidget.getViews());
190
+ }
191
+ return views;
192
+ }
193
+ }
194
+ }
195
+ fillGridNodes(target, node) {
196
+ if (isGridBranchNode(node)) {
197
+ node.children.forEach(child => this.fillGridNodes(target, child));
198
+ }
199
+ else {
200
+ target.push(node.view);
201
+ }
202
+ }
203
+ hasGroup(identifier) {
204
+ return ( this.groupViews.has(identifier));
205
+ }
206
+ getGroup(identifier) {
207
+ return this.groupViews.get(identifier);
208
+ }
209
+ findGroup(scope, source = this.activeGroup, wrap) {
210
+ if (typeof scope.direction === 'number') {
211
+ return this.doFindGroupByDirection(scope.direction, source, wrap);
212
+ }
213
+ if (typeof scope.location === 'number') {
214
+ return this.doFindGroupByLocation(scope.location, source, wrap);
215
+ }
216
+ throw new Error('invalid arguments');
217
+ }
218
+ doFindGroupByDirection(direction, source, wrap) {
219
+ const sourceGroupView = this.assertGroupView(source);
220
+ const neighbours = this.gridWidget.getNeighborViews(sourceGroupView, this.toGridViewDirection(direction), wrap);
221
+ neighbours.sort(((n1, n2) => this.mostRecentActiveGroups.indexOf(n1.id) - this.mostRecentActiveGroups.indexOf(n2.id)));
222
+ return neighbours[0];
223
+ }
224
+ doFindGroupByLocation(location, source, wrap) {
225
+ const sourceGroupView = this.assertGroupView(source);
226
+ const groups = this.getGroups(2 );
227
+ const index = groups.indexOf(sourceGroupView);
228
+ switch (location) {
229
+ case 0 :
230
+ return groups[0];
231
+ case 1 :
232
+ return groups[groups.length - 1];
233
+ case 2 : {
234
+ let nextGroup = groups[index + 1];
235
+ if (!nextGroup && wrap) {
236
+ nextGroup = this.doFindGroupByLocation(0 , source);
237
+ }
238
+ return nextGroup;
239
+ }
240
+ case 3 : {
241
+ let previousGroup = groups[index - 1];
242
+ if (!previousGroup && wrap) {
243
+ previousGroup = this.doFindGroupByLocation(1 , source);
244
+ }
245
+ return previousGroup;
246
+ }
247
+ }
248
+ }
249
+ activateGroup(group, preserveWindowOrder) {
250
+ const groupView = this.assertGroupView(group);
251
+ this.doSetGroupActive(groupView);
252
+ if (!preserveWindowOrder) {
253
+ this.hostService.moveTop(getWindow(this.element));
254
+ }
255
+ return groupView;
256
+ }
257
+ restoreGroup(group) {
258
+ const groupView = this.assertGroupView(group);
259
+ this.doRestoreGroup(groupView);
260
+ return groupView;
261
+ }
262
+ getSize(group) {
263
+ const groupView = this.assertGroupView(group);
264
+ return this.gridWidget.getViewSize(groupView);
265
+ }
266
+ setSize(group, size) {
267
+ const groupView = this.assertGroupView(group);
268
+ this.gridWidget.resizeView(groupView, size);
269
+ }
270
+ arrangeGroups(arrangement, target = this.activeGroup) {
271
+ if (this.count < 2) {
272
+ return;
273
+ }
274
+ if (!this.gridWidget) {
275
+ return;
276
+ }
277
+ const groupView = this.assertGroupView(target);
278
+ switch (arrangement) {
279
+ case 2 :
280
+ this.gridWidget.distributeViewSizes();
281
+ break;
282
+ case 0 :
283
+ if (this.groups.length < 2) {
284
+ return;
285
+ }
286
+ this.gridWidget.maximizeView(groupView);
287
+ groupView.focus();
288
+ break;
289
+ case 1 :
290
+ this.gridWidget.expandView(groupView);
291
+ break;
292
+ }
293
+ }
294
+ toggleMaximizeGroup(target = this.activeGroup) {
295
+ if (this.hasMaximizedGroup()) {
296
+ this.unmaximizeGroup();
297
+ }
298
+ else {
299
+ this.arrangeGroups(0 , target);
300
+ }
301
+ }
302
+ toggleExpandGroup(target = this.activeGroup) {
303
+ if (this.isGroupExpanded(this.activeGroup)) {
304
+ this.arrangeGroups(2 );
305
+ }
306
+ else {
307
+ this.arrangeGroups(1 , target);
308
+ }
309
+ }
310
+ unmaximizeGroup() {
311
+ this.gridWidget.exitMaximizedView();
312
+ this._activeGroup.focus();
313
+ }
314
+ hasMaximizedGroup() {
315
+ return this.gridWidget.hasMaximizedView();
316
+ }
317
+ isGroupMaximized(targetGroup) {
318
+ return this.gridWidget.isViewMaximized(targetGroup);
319
+ }
320
+ isGroupExpanded(targetGroup) {
321
+ return this.gridWidget.isViewExpanded(targetGroup);
322
+ }
323
+ setGroupOrientation(orientation) {
324
+ if (!this.gridWidget) {
325
+ return;
326
+ }
327
+ const newOrientation = ((orientation === 0) ) ? 1 : 0 ;
328
+ if (this.gridWidget.orientation !== newOrientation) {
329
+ this.gridWidget.orientation = newOrientation;
330
+ }
331
+ }
332
+ applyLayout(layout) {
333
+ const restoreFocus = this.shouldRestoreFocus(this.container);
334
+ let layoutGroupsCount = 0;
335
+ function countGroups(groups) {
336
+ for (const group of groups) {
337
+ if (Array.isArray(group.groups)) {
338
+ countGroups(group.groups);
339
+ }
340
+ else {
341
+ layoutGroupsCount++;
342
+ }
343
+ }
344
+ }
345
+ countGroups(layout.groups);
346
+ let currentGroupViews = this.getGroups(2 );
347
+ if (layoutGroupsCount < currentGroupViews.length) {
348
+ const lastGroupInLayout = currentGroupViews[layoutGroupsCount - 1];
349
+ currentGroupViews.forEach((group, index) => {
350
+ if (index >= layoutGroupsCount) {
351
+ this.mergeGroup(group, lastGroupInLayout);
352
+ }
353
+ });
354
+ currentGroupViews = this.getGroups(2 );
355
+ }
356
+ const activeGroup = this.activeGroup;
357
+ const gridDescriptor = createSerializedGrid({
358
+ orientation: this.toGridViewOrientation(layout.orientation, this.isTwoDimensionalGrid() ?
359
+ this.gridWidget.orientation :
360
+ orthogonal(this.gridWidget.orientation)
361
+ ),
362
+ groups: layout.groups
363
+ });
364
+ this.doApplyGridState(gridDescriptor, activeGroup.id, currentGroupViews);
365
+ if (restoreFocus) {
366
+ this._activeGroup.focus();
367
+ }
368
+ }
369
+ getLayout() {
370
+ const serializedGrid = this.gridWidget.serialize();
371
+ const orientation = serializedGrid.orientation === 1 ? 0 : 1 ;
372
+ const root = this.serializedNodeToGroupLayoutArgument(serializedGrid.root);
373
+ return {
374
+ orientation,
375
+ groups: root.groups
376
+ };
377
+ }
378
+ serializedNodeToGroupLayoutArgument(serializedNode) {
379
+ if (serializedNode.type === 'branch') {
380
+ return {
381
+ size: serializedNode.size,
382
+ groups: ( serializedNode.data.map(node => this.serializedNodeToGroupLayoutArgument(node)))
383
+ };
384
+ }
385
+ return { size: serializedNode.size };
386
+ }
387
+ shouldRestoreFocus(target) {
388
+ if (!target) {
389
+ return false;
390
+ }
391
+ const activeElement = getActiveElement();
392
+ if (activeElement === target.ownerDocument.body) {
393
+ return true;
394
+ }
395
+ return isAncestorOfActiveElement(target);
396
+ }
397
+ isTwoDimensionalGrid() {
398
+ const views = this.gridWidget.getViews();
399
+ if (isGridBranchNode(views)) {
400
+ return ( views.children.some(child => isGridBranchNode(child)));
401
+ }
402
+ return false;
403
+ }
404
+ addGroup(location, direction, groupToCopy) {
405
+ const locationView = this.assertGroupView(location);
406
+ let newGroupView;
407
+ if (locationView.groupsView === this) {
408
+ const restoreFocus = this.shouldRestoreFocus(locationView.element);
409
+ const shouldExpand = this.groupViews.size > 1 && this.isGroupExpanded(locationView);
410
+ newGroupView = this.doCreateGroupView(groupToCopy);
411
+ this.gridWidget.addView(newGroupView, this.getSplitSizingStyle(), locationView, this.toGridViewDirection(direction));
412
+ this.updateContainer();
413
+ this._onDidAddGroup.fire(newGroupView);
414
+ this.notifyGroupIndexChange();
415
+ if (shouldExpand) {
416
+ this.arrangeGroups(1 , newGroupView);
417
+ }
418
+ if (restoreFocus) {
419
+ locationView.focus();
420
+ }
421
+ }
422
+ else {
423
+ newGroupView = locationView.groupsView.addGroup(locationView, direction, groupToCopy);
424
+ }
425
+ return newGroupView;
426
+ }
427
+ getSplitSizingStyle() {
428
+ switch (this._partOptions.splitSizing) {
429
+ case 'distribute':
430
+ return Sizing.Distribute;
431
+ case 'split':
432
+ return Sizing.Split;
433
+ default:
434
+ return Sizing.Auto;
435
+ }
436
+ }
437
+ doCreateGroupView(from) {
438
+ let groupView;
439
+ if (from instanceof EditorGroupView) {
440
+ groupView = EditorGroupView.createCopy(from, this.editorPartsView, this, this.groupsLabel, this.count, this.scopedInstantiationService);
441
+ }
442
+ else if (isSerializedEditorGroupModel(from)) {
443
+ groupView = EditorGroupView.createFromSerialized(from, this.editorPartsView, this, this.groupsLabel, this.count, this.scopedInstantiationService);
444
+ }
445
+ else {
446
+ groupView = EditorGroupView.createNew(this.editorPartsView, this, this.groupsLabel, this.count, this.scopedInstantiationService);
447
+ }
448
+ this.groupViews.set(groupView.id, groupView);
449
+ const groupDisposables = ( new DisposableStore());
450
+ groupDisposables.add(groupView.onDidFocus(() => {
451
+ this.doSetGroupActive(groupView);
452
+ this._onDidFocus.fire();
453
+ }));
454
+ groupDisposables.add(groupView.onDidModelChange(e => {
455
+ switch (e.kind) {
456
+ case 3 :
457
+ this._onDidChangeGroupLocked.fire(groupView);
458
+ break;
459
+ case 1 :
460
+ this._onDidChangeGroupIndex.fire(groupView);
461
+ break;
462
+ case 2 :
463
+ this._onDidChangeGroupLabel.fire(groupView);
464
+ break;
465
+ }
466
+ }));
467
+ groupDisposables.add(groupView.onDidActiveEditorChange(() => {
468
+ this.updateContainer();
469
+ }));
470
+ Event.once(groupView.onWillDispose)(() => {
471
+ dispose(groupDisposables);
472
+ this.groupViews.delete(groupView.id);
473
+ this.doUpdateMostRecentActive(groupView);
474
+ });
475
+ return groupView;
476
+ }
477
+ doSetGroupActive(group) {
478
+ if (this._activeGroup !== group) {
479
+ const previousActiveGroup = this._activeGroup;
480
+ this._activeGroup = group;
481
+ this.doUpdateMostRecentActive(group, true);
482
+ if (previousActiveGroup && !previousActiveGroup.disposed) {
483
+ previousActiveGroup.setActive(false);
484
+ }
485
+ group.setActive(true);
486
+ this.doRestoreGroup(group);
487
+ this._onDidChangeActiveGroup.fire(group);
488
+ }
489
+ this._onDidActivateGroup.fire(group);
490
+ }
491
+ doRestoreGroup(group) {
492
+ if (!this.gridWidget) {
493
+ return;
494
+ }
495
+ if (this.hasMaximizedGroup() && !this.isGroupMaximized(group)) {
496
+ this.unmaximizeGroup();
497
+ }
498
+ try {
499
+ const viewSize = this.gridWidget.getViewSize(group);
500
+ if (viewSize.width === group.minimumWidth || viewSize.height === group.minimumHeight) {
501
+ this.arrangeGroups(1 , group);
502
+ }
503
+ }
504
+ catch (error) {
505
+ }
506
+ }
507
+ doUpdateMostRecentActive(group, makeMostRecentlyActive) {
508
+ const index = this.mostRecentActiveGroups.indexOf(group.id);
509
+ if (index !== -1) {
510
+ this.mostRecentActiveGroups.splice(index, 1);
511
+ }
512
+ if (makeMostRecentlyActive) {
513
+ this.mostRecentActiveGroups.unshift(group.id);
514
+ }
515
+ }
516
+ toGridViewDirection(direction) {
517
+ switch (direction) {
518
+ case 0 : return 0 ;
519
+ case 1 : return 1 ;
520
+ case 2 : return 2 ;
521
+ case 3 : return 3 ;
522
+ }
523
+ }
524
+ toGridViewOrientation(orientation, fallback) {
525
+ if (typeof orientation === 'number') {
526
+ return orientation === 0 ? 1 : 0 ;
527
+ }
528
+ return fallback;
529
+ }
530
+ removeGroup(group, preserveFocus) {
531
+ const groupView = this.assertGroupView(group);
532
+ if (this.count === 1) {
533
+ return;
534
+ }
535
+ if (groupView.isEmpty) {
536
+ this.doRemoveEmptyGroup(groupView, preserveFocus);
537
+ }
538
+ else {
539
+ this.doRemoveGroupWithEditors(groupView);
540
+ }
541
+ }
542
+ doRemoveGroupWithEditors(groupView) {
543
+ const mostRecentlyActiveGroups = this.getGroups(1 );
544
+ let lastActiveGroup;
545
+ if (this._activeGroup === groupView) {
546
+ lastActiveGroup = mostRecentlyActiveGroups[1];
547
+ }
548
+ else {
549
+ lastActiveGroup = mostRecentlyActiveGroups[0];
550
+ }
551
+ this.mergeGroup(groupView, lastActiveGroup);
552
+ }
553
+ doRemoveEmptyGroup(groupView, preserveFocus) {
554
+ const restoreFocus = !preserveFocus && this.shouldRestoreFocus(this.container);
555
+ if (this._activeGroup === groupView) {
556
+ const mostRecentlyActiveGroups = this.getGroups(1 );
557
+ const nextActiveGroup = mostRecentlyActiveGroups[1];
558
+ this.doSetGroupActive(nextActiveGroup);
559
+ }
560
+ this.gridWidget.removeView(groupView, this.getSplitSizingStyle());
561
+ groupView.dispose();
562
+ if (restoreFocus) {
563
+ this._activeGroup.focus();
564
+ }
565
+ this.notifyGroupIndexChange();
566
+ this.updateContainer();
567
+ this._onDidRemoveGroup.fire(groupView);
568
+ }
569
+ moveGroup(group, location, direction) {
570
+ const sourceView = this.assertGroupView(group);
571
+ const targetView = this.assertGroupView(location);
572
+ if (sourceView.id === targetView.id) {
573
+ throw new Error('Cannot move group into its own');
574
+ }
575
+ const restoreFocus = this.shouldRestoreFocus(sourceView.element);
576
+ let movedView;
577
+ if (sourceView.groupsView === targetView.groupsView) {
578
+ this.gridWidget.moveView(sourceView, this.getSplitSizingStyle(), targetView, this.toGridViewDirection(direction));
579
+ movedView = sourceView;
580
+ }
581
+ else {
582
+ movedView = targetView.groupsView.addGroup(targetView, direction, sourceView);
583
+ sourceView.closeAllEditors();
584
+ this.removeGroup(sourceView, restoreFocus);
585
+ }
586
+ if (restoreFocus) {
587
+ movedView.focus();
588
+ }
589
+ this._onDidMoveGroup.fire(movedView);
590
+ this.notifyGroupIndexChange();
591
+ return movedView;
592
+ }
593
+ copyGroup(group, location, direction) {
594
+ const groupView = this.assertGroupView(group);
595
+ const locationView = this.assertGroupView(location);
596
+ const restoreFocus = this.shouldRestoreFocus(groupView.element);
597
+ const copiedGroupView = this.addGroup(locationView, direction, groupView);
598
+ if (restoreFocus) {
599
+ copiedGroupView.focus();
600
+ }
601
+ return copiedGroupView;
602
+ }
603
+ mergeGroup(group, target, options) {
604
+ const sourceView = this.assertGroupView(group);
605
+ const targetView = this.assertGroupView(target);
606
+ const editors = [];
607
+ let index = (options && typeof options.index === 'number') ? options.index : targetView.count;
608
+ for (const editor of sourceView.editors) {
609
+ const inactive = !sourceView.isActive(editor) || this._activeGroup !== sourceView;
610
+ const sticky = sourceView.isSticky(editor);
611
+ const options = { index: !sticky ? index : undefined , inactive, preserveFocus: inactive };
612
+ editors.push({ editor, options });
613
+ index++;
614
+ }
615
+ if (options?.mode === 0 ) {
616
+ sourceView.copyEditors(editors, targetView);
617
+ }
618
+ else {
619
+ sourceView.moveEditors(editors, targetView);
620
+ }
621
+ if (sourceView.isEmpty && !sourceView.disposed ) {
622
+ this.removeGroup(sourceView, true);
623
+ }
624
+ return targetView;
625
+ }
626
+ mergeAllGroups(target) {
627
+ const targetView = this.assertGroupView(target);
628
+ for (const group of this.getGroups(1 )) {
629
+ if (group === targetView) {
630
+ continue;
631
+ }
632
+ this.mergeGroup(group, targetView);
633
+ }
634
+ return targetView;
635
+ }
636
+ assertGroupView(group) {
637
+ let groupView;
638
+ if (typeof group === 'number') {
639
+ groupView = this.editorPartsView.getGroup(group);
640
+ }
641
+ else {
642
+ groupView = group;
643
+ }
644
+ if (!groupView) {
645
+ throw new Error('Invalid editor group provided!');
646
+ }
647
+ return groupView;
648
+ }
649
+ createEditorDropTarget(container, delegate) {
650
+ assertType(container instanceof HTMLElement);
651
+ return this.scopedInstantiationService.createInstance(EditorDropTarget, container, delegate);
652
+ }
653
+ get minimumWidth() { return Math.min(this.centeredLayoutWidget.minimumWidth, this.layoutService.getMaximumEditorDimensions(this.layoutService.getContainer(getWindow(this.container))).width); }
654
+ get maximumWidth() { return this.centeredLayoutWidget.maximumWidth; }
655
+ get minimumHeight() { return Math.min(this.centeredLayoutWidget.minimumHeight, this.layoutService.getMaximumEditorDimensions(this.layoutService.getContainer(getWindow(this.container))).height); }
656
+ get maximumHeight() { return this.centeredLayoutWidget.maximumHeight; }
657
+ get snap() { return this.layoutService.getPanelAlignment() === 'center'; }
658
+ get onDidChange() { return Event.any(this.centeredLayoutWidget.onDidChange, this.onDidSetGridWidget.event); }
659
+ get gridSeparatorBorder() {
660
+ return this.theme.getColor(EDITOR_GROUP_BORDER) || this.theme.getColor(contrastBorder) || Color.transparent;
661
+ }
662
+ updateStyles() {
663
+ const container = assertIsDefined(this.container);
664
+ container.style.backgroundColor = this.getColor(editorBackground) || '';
665
+ const separatorBorderStyle = { separatorBorder: this.gridSeparatorBorder, background: this.theme.getColor(EDITOR_PANE_BACKGROUND) || Color.transparent };
666
+ this.gridWidget.style(separatorBorderStyle);
667
+ this.centeredLayoutWidget.styles(separatorBorderStyle);
668
+ }
669
+ createContentArea(parent, options) {
670
+ this.element = parent;
671
+ this.container = document.createElement('div');
672
+ this.container.classList.add('content');
673
+ if (this.windowId !== mainWindow.vscodeWindowId) {
674
+ this.container.classList.add('auxiliary');
675
+ }
676
+ parent.appendChild(this.container);
677
+ const scopedContextKeyService = this._register(this.contextKeyService.createScoped(this.container));
678
+ this.scopedInstantiationService = this.instantiationService.createChild(( new ServiceCollection([IContextKeyService, scopedContextKeyService])));
679
+ this._willRestoreState = !options || options.restorePreviousState;
680
+ this.doCreateGridControl();
681
+ this.centeredLayoutWidget = this._register(( new CenteredViewLayout(
682
+ this.container,
683
+ this.gridWidgetView,
684
+ this.profileMemento[EditorPart_1.EDITOR_PART_CENTERED_VIEW_STORAGE_KEY],
685
+ this._partOptions.centeredLayoutFixedWidth
686
+ )));
687
+ this._register(this.onDidChangeEditorPartOptions(e => this.centeredLayoutWidget.setFixedWidth(e.newPartOptions.centeredLayoutFixedWidth ?? false)));
688
+ this.setupDragAndDropSupport(parent, this.container);
689
+ this.handleContextKeys(scopedContextKeyService);
690
+ this.whenReadyPromise.complete();
691
+ this._isReady = true;
692
+ Promises.settled(( this.groups.map(group => group.whenRestored))).finally(() => {
693
+ this.whenRestoredPromise.complete();
694
+ });
695
+ return this.container;
696
+ }
697
+ handleContextKeys(contextKeyService) {
698
+ const isAuxiliaryEditorPartContext = IsAuxiliaryEditorPartContext.bindTo(contextKeyService);
699
+ isAuxiliaryEditorPartContext.set(this.windowId !== mainWindow.vscodeWindowId);
700
+ const multipleEditorGroupsContext = EditorPartMultipleEditorGroupsContext.bindTo(contextKeyService);
701
+ const maximizedEditorGroupContext = EditorPartMaximizedEditorGroupContext.bindTo(contextKeyService);
702
+ const updateContextKeys = () => {
703
+ const groupCount = this.count;
704
+ if (groupCount > 1) {
705
+ multipleEditorGroupsContext.set(true);
706
+ }
707
+ else {
708
+ multipleEditorGroupsContext.reset();
709
+ }
710
+ if (this.hasMaximizedGroup()) {
711
+ maximizedEditorGroupContext.set(true);
712
+ }
713
+ else {
714
+ maximizedEditorGroupContext.reset();
715
+ }
716
+ };
717
+ updateContextKeys();
718
+ this._register(this.onDidAddGroup(() => updateContextKeys()));
719
+ this._register(this.onDidRemoveGroup(() => updateContextKeys()));
720
+ this._register(this.onDidChangeGroupMaximized(() => updateContextKeys()));
721
+ }
722
+ setupDragAndDropSupport(parent, container) {
723
+ this._register(this.createEditorDropTarget(container, Object.create(null)));
724
+ const overlay = document.createElement('div');
725
+ overlay.classList.add('drop-block-overlay');
726
+ parent.appendChild(overlay);
727
+ this._register(addDisposableGenericMouseDownListener(overlay, () => overlay.classList.remove('visible')));
728
+ this._register(CompositeDragAndDropObserver.INSTANCE.registerTarget(this.element, {
729
+ onDragStart: e => overlay.classList.add('visible'),
730
+ onDragEnd: e => overlay.classList.remove('visible')
731
+ }));
732
+ let horizontalOpenerTimeout;
733
+ let verticalOpenerTimeout;
734
+ let lastOpenHorizontalPosition;
735
+ let lastOpenVerticalPosition;
736
+ const openPartAtPosition = (position) => {
737
+ if (!this.layoutService.isVisible("workbench.parts.panel" ) && position === this.layoutService.getPanelPosition()) {
738
+ this.layoutService.setPartHidden(false, "workbench.parts.panel" );
739
+ }
740
+ else if (!this.layoutService.isVisible("workbench.parts.auxiliarybar" ) && position === ((this.layoutService.getSideBarPosition() === 1 ? 0 : 1) )) {
741
+ this.layoutService.setPartHidden(false, "workbench.parts.auxiliarybar" );
742
+ }
743
+ };
744
+ const clearAllTimeouts = () => {
745
+ if (horizontalOpenerTimeout) {
746
+ clearTimeout(horizontalOpenerTimeout);
747
+ horizontalOpenerTimeout = undefined;
748
+ }
749
+ if (verticalOpenerTimeout) {
750
+ clearTimeout(verticalOpenerTimeout);
751
+ verticalOpenerTimeout = undefined;
752
+ }
753
+ };
754
+ this._register(CompositeDragAndDropObserver.INSTANCE.registerTarget(overlay, {
755
+ onDragOver: e => {
756
+ EventHelper.stop(e.eventData, true);
757
+ if (e.eventData.dataTransfer) {
758
+ e.eventData.dataTransfer.dropEffect = 'none';
759
+ }
760
+ const boundingRect = overlay.getBoundingClientRect();
761
+ let openHorizontalPosition = undefined;
762
+ let openVerticalPosition = undefined;
763
+ const proximity = 100;
764
+ if (e.eventData.clientX < boundingRect.left + proximity) {
765
+ openHorizontalPosition = 0 ;
766
+ }
767
+ if (e.eventData.clientX > boundingRect.right - proximity) {
768
+ openHorizontalPosition = 1 ;
769
+ }
770
+ if (e.eventData.clientY > boundingRect.bottom - proximity) {
771
+ openVerticalPosition = 2 ;
772
+ }
773
+ if (horizontalOpenerTimeout && openHorizontalPosition !== lastOpenHorizontalPosition) {
774
+ clearTimeout(horizontalOpenerTimeout);
775
+ horizontalOpenerTimeout = undefined;
776
+ }
777
+ if (verticalOpenerTimeout && openVerticalPosition !== lastOpenVerticalPosition) {
778
+ clearTimeout(verticalOpenerTimeout);
779
+ verticalOpenerTimeout = undefined;
780
+ }
781
+ if (!horizontalOpenerTimeout && openHorizontalPosition !== undefined) {
782
+ lastOpenHorizontalPosition = openHorizontalPosition;
783
+ horizontalOpenerTimeout = setTimeout(() => openPartAtPosition(openHorizontalPosition), 200);
784
+ }
785
+ if (!verticalOpenerTimeout && openVerticalPosition !== undefined) {
786
+ lastOpenVerticalPosition = openVerticalPosition;
787
+ verticalOpenerTimeout = setTimeout(() => openPartAtPosition(openVerticalPosition), 200);
788
+ }
789
+ },
790
+ onDragLeave: () => clearAllTimeouts(),
791
+ onDragEnd: () => clearAllTimeouts(),
792
+ onDrop: () => clearAllTimeouts()
793
+ }));
794
+ }
795
+ centerLayout(active) {
796
+ this.centeredLayoutWidget.activate(active);
797
+ this._activeGroup.focus();
798
+ }
799
+ isLayoutCentered() {
800
+ if (this.centeredLayoutWidget) {
801
+ return this.centeredLayoutWidget.isActive();
802
+ }
803
+ return false;
804
+ }
805
+ doCreateGridControl() {
806
+ let restoreError = false;
807
+ if (this._willRestoreState) {
808
+ restoreError = !this.doCreateGridControlWithPreviousState();
809
+ }
810
+ if (!this.gridWidget || restoreError) {
811
+ const initialGroup = this.doCreateGroupView();
812
+ this.doSetGridWidget(( new SerializableGrid(initialGroup)));
813
+ this.doSetGroupActive(initialGroup);
814
+ }
815
+ this.updateContainer();
816
+ this.notifyGroupIndexChange();
817
+ }
818
+ doCreateGridControlWithPreviousState() {
819
+ const state = this.loadState();
820
+ if (state?.serializedGrid) {
821
+ try {
822
+ this.mostRecentActiveGroups = state.mostRecentActiveGroups;
823
+ this.doCreateGridControlWithState(state.serializedGrid, state.activeGroup);
824
+ }
825
+ catch (error) {
826
+ onUnexpectedError(( new Error(
827
+ `Error restoring editor grid widget: ${error} (with state: ${JSON.stringify(state)})`
828
+ )));
829
+ this.disposeGroups();
830
+ return false;
831
+ }
832
+ }
833
+ return true;
834
+ }
835
+ doCreateGridControlWithState(serializedGrid, activeGroupId, editorGroupViewsToReuse) {
836
+ let reuseGroupViews;
837
+ if (editorGroupViewsToReuse) {
838
+ reuseGroupViews = editorGroupViewsToReuse.slice(0);
839
+ }
840
+ else {
841
+ reuseGroupViews = [];
842
+ }
843
+ const groupViews = [];
844
+ const gridWidget = SerializableGrid.deserialize(serializedGrid, {
845
+ fromJSON: (serializedEditorGroup) => {
846
+ let groupView;
847
+ if (reuseGroupViews.length > 0) {
848
+ groupView = reuseGroupViews.shift();
849
+ }
850
+ else {
851
+ groupView = this.doCreateGroupView(serializedEditorGroup);
852
+ }
853
+ groupViews.push(groupView);
854
+ if (groupView.id === activeGroupId) {
855
+ this.doSetGroupActive(groupView);
856
+ }
857
+ return groupView;
858
+ }
859
+ }, { styles: { separatorBorder: this.gridSeparatorBorder } });
860
+ if (!this._activeGroup) {
861
+ this.doSetGroupActive(groupViews[0]);
862
+ }
863
+ if (( this.mostRecentActiveGroups.some(groupId => !this.getGroup(groupId)))) {
864
+ this.mostRecentActiveGroups = ( groupViews.map(group => group.id));
865
+ }
866
+ this.doSetGridWidget(gridWidget);
867
+ }
868
+ doSetGridWidget(gridWidget) {
869
+ let boundarySashes = {};
870
+ if (this.gridWidget) {
871
+ boundarySashes = this.gridWidget.boundarySashes;
872
+ this.gridWidget.dispose();
873
+ }
874
+ this.gridWidget = gridWidget;
875
+ this.gridWidget.boundarySashes = boundarySashes;
876
+ this.gridWidgetView.gridWidget = gridWidget;
877
+ this._onDidChangeSizeConstraints.input = gridWidget.onDidChange;
878
+ this._onDidScroll.input = gridWidget.onDidScroll;
879
+ this.gridWidgetDisposables.clear();
880
+ this.gridWidgetDisposables.add(gridWidget.onDidChangeViewMaximized(maximized => this._onDidChangeGroupMaximized.fire(maximized)));
881
+ this._onDidChangeGroupMaximized.fire(this.hasMaximizedGroup());
882
+ this.onDidSetGridWidget.fire(undefined);
883
+ }
884
+ updateContainer() {
885
+ const container = assertIsDefined(this.container);
886
+ container.classList.toggle('empty', this.isEmpty);
887
+ }
888
+ notifyGroupIndexChange() {
889
+ this.getGroups(2 ).forEach((group, index) => group.notifyIndexChanged(index));
890
+ }
891
+ notifyGroupsLabelChange(newLabel) {
892
+ for (const group of this.groups) {
893
+ group.notifyLabelChanged(newLabel);
894
+ }
895
+ }
896
+ get isEmpty() {
897
+ return this.count === 1 && this._activeGroup.isEmpty;
898
+ }
899
+ setBoundarySashes(sashes) {
900
+ this.gridWidget.boundarySashes = sashes;
901
+ this.centeredLayoutWidget.boundarySashes = sashes;
902
+ }
903
+ layout(width, height, top, left) {
904
+ this.top = top;
905
+ this.left = left;
906
+ const contentAreaSize = super.layoutContents(width, height).contentSize;
907
+ this.doLayout(Dimension.lift(contentAreaSize), top, left);
908
+ }
909
+ doLayout(dimension, top = this.top, left = this.left) {
910
+ this._contentDimension = dimension;
911
+ this.centeredLayoutWidget.layout(this._contentDimension.width, this._contentDimension.height, top, left);
912
+ this._onDidLayout.fire(dimension);
913
+ }
914
+ saveState() {
915
+ if (this.gridWidget) {
916
+ if (this.isEmpty) {
917
+ delete this.workspaceMemento[EditorPart_1.EDITOR_PART_UI_STATE_STORAGE_KEY];
918
+ }
919
+ else {
920
+ this.workspaceMemento[EditorPart_1.EDITOR_PART_UI_STATE_STORAGE_KEY] = this.createState();
921
+ }
922
+ }
923
+ if (this.centeredLayoutWidget) {
924
+ const centeredLayoutState = this.centeredLayoutWidget.state;
925
+ if (this.centeredLayoutWidget.isDefault(centeredLayoutState)) {
926
+ delete this.profileMemento[EditorPart_1.EDITOR_PART_CENTERED_VIEW_STORAGE_KEY];
927
+ }
928
+ else {
929
+ this.profileMemento[EditorPart_1.EDITOR_PART_CENTERED_VIEW_STORAGE_KEY] = centeredLayoutState;
930
+ }
931
+ }
932
+ super.saveState();
933
+ }
934
+ loadState() {
935
+ return this.workspaceMemento[EditorPart_1.EDITOR_PART_UI_STATE_STORAGE_KEY];
936
+ }
937
+ createState() {
938
+ return {
939
+ serializedGrid: this.gridWidget.serialize(),
940
+ activeGroup: this._activeGroup.id,
941
+ mostRecentActiveGroups: this.mostRecentActiveGroups
942
+ };
943
+ }
944
+ async applyState(state) {
945
+ for (const group of this.getGroups(1 )) {
946
+ const closed = await group.closeAllEditors();
947
+ if (!closed) {
948
+ return false;
949
+ }
950
+ }
951
+ this.disposeGroups();
952
+ this.mostRecentActiveGroups = state.mostRecentActiveGroups;
953
+ this.doApplyGridState(state.serializedGrid, state.activeGroup);
954
+ return true;
955
+ }
956
+ doApplyGridState(gridState, activeGroupId, editorGroupViewsToReuse) {
957
+ this.doCreateGridControlWithState(gridState, activeGroupId, editorGroupViewsToReuse);
958
+ this.doLayout(this._contentDimension);
959
+ this.updateContainer();
960
+ for (const groupView of this.getGroups(2 )) {
961
+ if (!editorGroupViewsToReuse?.includes(groupView)) {
962
+ this._onDidAddGroup.fire(groupView);
963
+ }
964
+ }
965
+ this.notifyGroupIndexChange();
966
+ }
967
+ onDidChangeMementoState(e) {
968
+ if (e.external && e.scope === 1 ) {
969
+ this.reloadMemento(e.scope);
970
+ const state = this.loadState();
971
+ if (state) {
972
+ this.applyState(state);
973
+ }
974
+ }
975
+ }
976
+ toJSON() {
977
+ return {
978
+ type: "workbench.parts.editor"
979
+ };
980
+ }
981
+ disposeGroups() {
982
+ for (const group of this.groups) {
983
+ group.dispose();
984
+ this._onDidRemoveGroup.fire(group);
985
+ }
986
+ this.groupViews.clear();
987
+ this.mostRecentActiveGroups = [];
988
+ }
989
+ dispose() {
990
+ this.disposeGroups();
991
+ this.gridWidget?.dispose();
992
+ super.dispose();
993
+ }
994
+ };
995
+ EditorPart = EditorPart_1 = ( __decorate([
996
+ ( __param(4, IInstantiationService)),
997
+ ( __param(5, IThemeService)),
998
+ ( __param(6, IConfigurationService)),
999
+ ( __param(7, IStorageService)),
1000
+ ( __param(8, IWorkbenchLayoutService)),
1001
+ ( __param(9, IHostService)),
1002
+ ( __param(10, IContextKeyService))
1003
+ ], EditorPart));
1004
+ let MainEditorPart = class MainEditorPart extends EditorPart {
1005
+ constructor(editorPartsView, instantiationService, themeService, configurationService, storageService, layoutService, hostService, contextKeyService) {
1006
+ super(editorPartsView, "workbench.parts.editor" , '', mainWindow.vscodeWindowId, instantiationService, themeService, configurationService, storageService, layoutService, hostService, contextKeyService);
1007
+ }
1008
+ };
1009
+ MainEditorPart = ( __decorate([
1010
+ ( __param(1, IInstantiationService)),
1011
+ ( __param(2, IThemeService)),
1012
+ ( __param(3, IConfigurationService)),
1013
+ ( __param(4, IStorageService)),
1014
+ ( __param(5, IWorkbenchLayoutService)),
1015
+ ( __param(6, IHostService)),
1016
+ ( __param(7, IContextKeyService))
1017
+ ], MainEditorPart));
1018
+ export { EditorPart, MainEditorPart };