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

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