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