dockview 1.7.3 → 1.7.4
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.
- package/dist/dockview.amd.js +280 -189
- package/dist/dockview.amd.min.js +2 -2
- package/dist/dockview.amd.min.noStyle.js +2 -2
- package/dist/dockview.amd.noStyle.js +280 -189
- package/dist/dockview.cjs.js +280 -189
- package/dist/dockview.esm.js +280 -189
- package/dist/dockview.esm.min.js +2 -2
- package/dist/dockview.js +280 -189
- package/dist/dockview.min.js +2 -2
- package/dist/dockview.min.noStyle.js +2 -2
- package/dist/dockview.noStyle.js +280 -189
- package/package.json +3 -3
package/dist/dockview.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dockview
|
|
3
|
-
* @version 1.7.
|
|
3
|
+
* @version 1.7.4
|
|
4
4
|
* @link https://github.com/mathuo/dockview
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
@@ -122,9 +122,49 @@ var Event;
|
|
|
122
122
|
};
|
|
123
123
|
};
|
|
124
124
|
})(Event || (Event = {}));
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
class LeakageMonitor {
|
|
126
|
+
constructor() {
|
|
127
|
+
this.events = new Map();
|
|
128
|
+
}
|
|
129
|
+
get size() {
|
|
130
|
+
return this.events.size;
|
|
131
|
+
}
|
|
132
|
+
add(event, stacktrace) {
|
|
133
|
+
this.events.set(event, stacktrace);
|
|
134
|
+
}
|
|
135
|
+
delete(event) {
|
|
136
|
+
this.events.delete(event);
|
|
137
|
+
}
|
|
138
|
+
clear() {
|
|
139
|
+
this.events.clear();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
class Stacktrace {
|
|
143
|
+
static create() {
|
|
144
|
+
var _a;
|
|
145
|
+
return new Stacktrace((_a = new Error().stack) !== null && _a !== void 0 ? _a : '');
|
|
146
|
+
}
|
|
147
|
+
constructor(value) {
|
|
148
|
+
this.value = value;
|
|
149
|
+
}
|
|
150
|
+
print() {
|
|
151
|
+
console.warn(this.value);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
class Listener {
|
|
155
|
+
constructor(callback, stacktrace) {
|
|
156
|
+
this.callback = callback;
|
|
157
|
+
this.stacktrace = stacktrace;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// relatively simple event emitter taken from https://github.com/microsoft/vscode/blob/master/src/vs/base/common/event.ts
|
|
127
161
|
class Emitter {
|
|
162
|
+
static setLeakageMonitorEnabled(isEnabled) {
|
|
163
|
+
if (isEnabled !== Emitter.ENABLE_TRACKING) {
|
|
164
|
+
Emitter.MEMORY_LEAK_WATCHER.clear();
|
|
165
|
+
}
|
|
166
|
+
Emitter.ENABLE_TRACKING = isEnabled;
|
|
167
|
+
}
|
|
128
168
|
constructor(options) {
|
|
129
169
|
this.options = options;
|
|
130
170
|
this._listeners = [];
|
|
@@ -132,11 +172,12 @@ class Emitter {
|
|
|
132
172
|
}
|
|
133
173
|
get event() {
|
|
134
174
|
if (!this._event) {
|
|
135
|
-
this._event = (
|
|
175
|
+
this._event = (callback) => {
|
|
136
176
|
var _a;
|
|
137
177
|
if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.replay) && this._last !== undefined) {
|
|
138
|
-
|
|
178
|
+
callback(this._last);
|
|
139
179
|
}
|
|
180
|
+
const listener = new Listener(callback, Emitter.ENABLE_TRACKING ? Stacktrace.create() : undefined);
|
|
140
181
|
this._listeners.push(listener);
|
|
141
182
|
return {
|
|
142
183
|
dispose: () => {
|
|
@@ -144,23 +185,45 @@ class Emitter {
|
|
|
144
185
|
if (index > -1) {
|
|
145
186
|
this._listeners.splice(index, 1);
|
|
146
187
|
}
|
|
188
|
+
else if (Emitter.ENABLE_TRACKING) ;
|
|
147
189
|
},
|
|
148
190
|
};
|
|
149
191
|
};
|
|
192
|
+
if (Emitter.ENABLE_TRACKING) {
|
|
193
|
+
Emitter.MEMORY_LEAK_WATCHER.add(this._event, Stacktrace.create());
|
|
194
|
+
}
|
|
150
195
|
}
|
|
151
196
|
return this._event;
|
|
152
197
|
}
|
|
153
198
|
fire(e) {
|
|
154
199
|
this._last = e;
|
|
155
200
|
for (const listener of this._listeners) {
|
|
156
|
-
listener(e);
|
|
201
|
+
listener.callback(e);
|
|
157
202
|
}
|
|
158
203
|
}
|
|
159
204
|
dispose() {
|
|
160
|
-
this.
|
|
161
|
-
|
|
205
|
+
if (!this._disposed) {
|
|
206
|
+
this._disposed = true;
|
|
207
|
+
if (this._listeners.length > 0) {
|
|
208
|
+
if (Emitter.ENABLE_TRACKING) {
|
|
209
|
+
queueMicrotask(() => {
|
|
210
|
+
var _a;
|
|
211
|
+
// don't check until stack of execution is completed to allow for out-of-order disposals within the same execution block
|
|
212
|
+
for (const listener of this._listeners) {
|
|
213
|
+
console.warn((_a = listener.stacktrace) === null || _a === void 0 ? void 0 : _a.print());
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
this._listeners = [];
|
|
218
|
+
}
|
|
219
|
+
if (Emitter.ENABLE_TRACKING && this._event) {
|
|
220
|
+
Emitter.MEMORY_LEAK_WATCHER.delete(this._event);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
162
223
|
}
|
|
163
224
|
}
|
|
225
|
+
Emitter.ENABLE_TRACKING = false;
|
|
226
|
+
Emitter.MEMORY_LEAK_WATCHER = new LeakageMonitor();
|
|
164
227
|
function addDisposableWindowListener(element, type, listener, options) {
|
|
165
228
|
element.addEventListener(type, listener, options);
|
|
166
229
|
return {
|
|
@@ -213,13 +276,13 @@ class CompositeDisposable {
|
|
|
213
276
|
}
|
|
214
277
|
constructor(...args) {
|
|
215
278
|
this._isDisposed = false;
|
|
216
|
-
this.
|
|
279
|
+
this._disposables = args;
|
|
217
280
|
}
|
|
218
281
|
addDisposables(...args) {
|
|
219
|
-
args.forEach((arg) => this.
|
|
282
|
+
args.forEach((arg) => this._disposables.push(arg));
|
|
220
283
|
}
|
|
221
284
|
dispose() {
|
|
222
|
-
this.
|
|
285
|
+
this._disposables.forEach((arg) => arg.dispose());
|
|
223
286
|
this._isDisposed = true;
|
|
224
287
|
}
|
|
225
288
|
}
|
|
@@ -309,6 +372,7 @@ class FocusTracker extends CompositeDisposable {
|
|
|
309
372
|
this.onDidFocus = this._onDidFocus.event;
|
|
310
373
|
this._onDidBlur = new Emitter();
|
|
311
374
|
this.onDidBlur = this._onDidBlur.event;
|
|
375
|
+
this.addDisposables(this._onDidFocus, this._onDidBlur);
|
|
312
376
|
let hasFocus = isAncestor(document.activeElement, element);
|
|
313
377
|
let loosingFocus = false;
|
|
314
378
|
const onFocus = () => {
|
|
@@ -353,11 +417,6 @@ class FocusTracker extends CompositeDisposable {
|
|
|
353
417
|
refreshState() {
|
|
354
418
|
this._refreshStateHandler();
|
|
355
419
|
}
|
|
356
|
-
dispose() {
|
|
357
|
-
super.dispose();
|
|
358
|
-
this._onDidBlur.dispose();
|
|
359
|
-
this._onDidFocus.dispose();
|
|
360
|
-
}
|
|
361
420
|
}
|
|
362
421
|
|
|
363
422
|
function createComponent(id, componentName, components = {}, frameworkComponents = {}, createFrameworkComponent, fallback) {
|
|
@@ -586,7 +645,7 @@ class Splitview {
|
|
|
586
645
|
this._orthogonalSize = value;
|
|
587
646
|
}
|
|
588
647
|
get length() {
|
|
589
|
-
return this.
|
|
648
|
+
return this.viewItems.length;
|
|
590
649
|
}
|
|
591
650
|
get proportions() {
|
|
592
651
|
return this._proportions ? [...this._proportions] : undefined;
|
|
@@ -605,12 +664,12 @@ class Splitview {
|
|
|
605
664
|
: 'vertical');
|
|
606
665
|
}
|
|
607
666
|
get minimumSize() {
|
|
608
|
-
return this.
|
|
667
|
+
return this.viewItems.reduce((r, item) => r + item.minimumSize, 0);
|
|
609
668
|
}
|
|
610
669
|
get maximumSize() {
|
|
611
670
|
return this.length === 0
|
|
612
671
|
? Number.POSITIVE_INFINITY
|
|
613
|
-
: this.
|
|
672
|
+
: this.viewItems.reduce((r, item) => r + item.maximumSize, 0);
|
|
614
673
|
}
|
|
615
674
|
get startSnappingEnabled() {
|
|
616
675
|
return this._startSnappingEnabled;
|
|
@@ -634,7 +693,7 @@ class Splitview {
|
|
|
634
693
|
}
|
|
635
694
|
constructor(container, options) {
|
|
636
695
|
this.container = container;
|
|
637
|
-
this.
|
|
696
|
+
this.viewItems = [];
|
|
638
697
|
this.sashes = [];
|
|
639
698
|
this._size = 0;
|
|
640
699
|
this._orthogonalSize = 0;
|
|
@@ -648,12 +707,12 @@ class Splitview {
|
|
|
648
707
|
this.onDidAddView = this._onDidAddView.event;
|
|
649
708
|
this._onDidRemoveView = new Emitter();
|
|
650
709
|
this.onDidRemoveView = this._onDidRemoveView.event;
|
|
651
|
-
this.resize = (index, delta, sizes = this.
|
|
652
|
-
if (index < 0 || index > this.
|
|
710
|
+
this.resize = (index, delta, sizes = this.viewItems.map((x) => x.size), lowPriorityIndexes, highPriorityIndexes, overloadMinDelta = Number.NEGATIVE_INFINITY, overloadMaxDelta = Number.POSITIVE_INFINITY, snapBefore, snapAfter) => {
|
|
711
|
+
if (index < 0 || index > this.viewItems.length) {
|
|
653
712
|
return 0;
|
|
654
713
|
}
|
|
655
714
|
const upIndexes = range(index, -1);
|
|
656
|
-
const downIndexes = range(index + 1, this.
|
|
715
|
+
const downIndexes = range(index + 1, this.viewItems.length);
|
|
657
716
|
//
|
|
658
717
|
if (highPriorityIndexes) {
|
|
659
718
|
for (const i of highPriorityIndexes) {
|
|
@@ -668,34 +727,34 @@ class Splitview {
|
|
|
668
727
|
}
|
|
669
728
|
}
|
|
670
729
|
//
|
|
671
|
-
const upItems = upIndexes.map((i) => this.
|
|
730
|
+
const upItems = upIndexes.map((i) => this.viewItems[i]);
|
|
672
731
|
const upSizes = upIndexes.map((i) => sizes[i]);
|
|
673
732
|
//
|
|
674
|
-
const downItems = downIndexes.map((i) => this.
|
|
733
|
+
const downItems = downIndexes.map((i) => this.viewItems[i]);
|
|
675
734
|
const downSizes = downIndexes.map((i) => sizes[i]);
|
|
676
735
|
//
|
|
677
|
-
const minDeltaUp = upIndexes.reduce((_, i) => _ + this.
|
|
678
|
-
const maxDeltaUp = upIndexes.reduce((_, i) => _ + this.
|
|
736
|
+
const minDeltaUp = upIndexes.reduce((_, i) => _ + this.viewItems[i].minimumSize - sizes[i], 0);
|
|
737
|
+
const maxDeltaUp = upIndexes.reduce((_, i) => _ + this.viewItems[i].maximumSize - sizes[i], 0);
|
|
679
738
|
//
|
|
680
739
|
const maxDeltaDown = downIndexes.length === 0
|
|
681
740
|
? Number.POSITIVE_INFINITY
|
|
682
|
-
: downIndexes.reduce((_, i) => _ + sizes[i] - this.
|
|
741
|
+
: downIndexes.reduce((_, i) => _ + sizes[i] - this.viewItems[i].minimumSize, 0);
|
|
683
742
|
const minDeltaDown = downIndexes.length === 0
|
|
684
743
|
? Number.NEGATIVE_INFINITY
|
|
685
|
-
: downIndexes.reduce((_, i) => _ + sizes[i] - this.
|
|
744
|
+
: downIndexes.reduce((_, i) => _ + sizes[i] - this.viewItems[i].maximumSize, 0);
|
|
686
745
|
//
|
|
687
746
|
const minDelta = Math.max(minDeltaUp, minDeltaDown);
|
|
688
747
|
const maxDelta = Math.min(maxDeltaDown, maxDeltaUp);
|
|
689
748
|
//
|
|
690
749
|
let snapped = false;
|
|
691
750
|
if (snapBefore) {
|
|
692
|
-
const snapView = this.
|
|
751
|
+
const snapView = this.viewItems[snapBefore.index];
|
|
693
752
|
const visible = delta >= snapBefore.limitDelta;
|
|
694
753
|
snapped = visible !== snapView.visible;
|
|
695
754
|
snapView.setVisible(visible, snapBefore.size);
|
|
696
755
|
}
|
|
697
756
|
if (!snapped && snapAfter) {
|
|
698
|
-
const snapView = this.
|
|
757
|
+
const snapView = this.viewItems[snapAfter.index];
|
|
699
758
|
const visible = delta < snapAfter.limitDelta;
|
|
700
759
|
snapped = visible !== snapView.visible;
|
|
701
760
|
snapView.setVisible(visible, snapAfter.size);
|
|
@@ -757,7 +816,7 @@ class Splitview {
|
|
|
757
816
|
);
|
|
758
817
|
});
|
|
759
818
|
// Initialize content size and proportions for first layout
|
|
760
|
-
this.contentSize = this.
|
|
819
|
+
this.contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
|
|
761
820
|
this.saveProportions();
|
|
762
821
|
}
|
|
763
822
|
}
|
|
@@ -774,18 +833,18 @@ class Splitview {
|
|
|
774
833
|
}
|
|
775
834
|
}
|
|
776
835
|
isViewVisible(index) {
|
|
777
|
-
if (index < 0 || index >= this.
|
|
836
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
778
837
|
throw new Error('Index out of bounds');
|
|
779
838
|
}
|
|
780
|
-
const viewItem = this.
|
|
839
|
+
const viewItem = this.viewItems[index];
|
|
781
840
|
return viewItem.visible;
|
|
782
841
|
}
|
|
783
842
|
setViewVisible(index, visible) {
|
|
784
|
-
if (index < 0 || index >= this.
|
|
843
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
785
844
|
throw new Error('Index out of bounds');
|
|
786
845
|
}
|
|
787
846
|
toggleClass(this.container, 'visible', visible);
|
|
788
|
-
const viewItem = this.
|
|
847
|
+
const viewItem = this.viewItems[index];
|
|
789
848
|
toggleClass(this.container, 'visible', visible);
|
|
790
849
|
viewItem.setVisible(visible, viewItem.size);
|
|
791
850
|
this.distributeEmptySpace(index);
|
|
@@ -793,33 +852,33 @@ class Splitview {
|
|
|
793
852
|
this.saveProportions();
|
|
794
853
|
}
|
|
795
854
|
getViewSize(index) {
|
|
796
|
-
if (index < 0 || index >= this.
|
|
855
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
797
856
|
return -1;
|
|
798
857
|
}
|
|
799
|
-
return this.
|
|
858
|
+
return this.viewItems[index].size;
|
|
800
859
|
}
|
|
801
860
|
resizeView(index, size) {
|
|
802
|
-
if (index < 0 || index >= this.
|
|
861
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
803
862
|
return;
|
|
804
863
|
}
|
|
805
|
-
const indexes = range(this.
|
|
864
|
+
const indexes = range(this.viewItems.length).filter((i) => i !== index);
|
|
806
865
|
const lowPriorityIndexes = [
|
|
807
|
-
...indexes.filter((i) => this.
|
|
866
|
+
...indexes.filter((i) => this.viewItems[i].priority === LayoutPriority.Low),
|
|
808
867
|
index,
|
|
809
868
|
];
|
|
810
|
-
const highPriorityIndexes = indexes.filter((i) => this.
|
|
811
|
-
const item = this.
|
|
869
|
+
const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === LayoutPriority.High);
|
|
870
|
+
const item = this.viewItems[index];
|
|
812
871
|
size = Math.round(size);
|
|
813
872
|
size = clamp(size, item.minimumSize, Math.min(item.maximumSize, this._size));
|
|
814
873
|
item.size = size;
|
|
815
874
|
this.relayout(lowPriorityIndexes, highPriorityIndexes);
|
|
816
875
|
}
|
|
817
876
|
getViews() {
|
|
818
|
-
return this.
|
|
877
|
+
return this.viewItems.map((x) => x.view);
|
|
819
878
|
}
|
|
820
879
|
onDidChange(item, size) {
|
|
821
|
-
const index = this.
|
|
822
|
-
if (index < 0 || index >= this.
|
|
880
|
+
const index = this.viewItems.indexOf(item);
|
|
881
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
823
882
|
return;
|
|
824
883
|
}
|
|
825
884
|
size = typeof size === 'number' ? size : item.size;
|
|
@@ -827,7 +886,7 @@ class Splitview {
|
|
|
827
886
|
item.size = size;
|
|
828
887
|
this.relayout([index]);
|
|
829
888
|
}
|
|
830
|
-
addView(view, size = { type: 'distribute' }, index = this.
|
|
889
|
+
addView(view, size = { type: 'distribute' }, index = this.viewItems.length, skipLayout) {
|
|
831
890
|
const container = document.createElement('div');
|
|
832
891
|
container.className = 'view';
|
|
833
892
|
container.appendChild(view.element);
|
|
@@ -845,24 +904,25 @@ class Splitview {
|
|
|
845
904
|
viewSize = view.minimumSize;
|
|
846
905
|
}
|
|
847
906
|
const disposable = view.onDidChange((newSize) => this.onDidChange(viewItem, newSize.size));
|
|
848
|
-
const
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
907
|
+
const viewItem = new ViewItem(container, view, viewSize, {
|
|
908
|
+
dispose: () => {
|
|
909
|
+
disposable.dispose();
|
|
910
|
+
this.viewContainer.removeChild(container);
|
|
911
|
+
},
|
|
912
|
+
});
|
|
913
|
+
if (index === this.viewItems.length) {
|
|
854
914
|
this.viewContainer.appendChild(container);
|
|
855
915
|
}
|
|
856
916
|
else {
|
|
857
917
|
this.viewContainer.insertBefore(container, this.viewContainer.children.item(index));
|
|
858
918
|
}
|
|
859
|
-
this.
|
|
860
|
-
if (this.
|
|
919
|
+
this.viewItems.splice(index, 0, viewItem);
|
|
920
|
+
if (this.viewItems.length > 1) {
|
|
861
921
|
//add sash
|
|
862
922
|
const sash = document.createElement('div');
|
|
863
923
|
sash.className = 'sash';
|
|
864
924
|
const onStart = (event) => {
|
|
865
|
-
for (const item of this.
|
|
925
|
+
for (const item of this.viewItems) {
|
|
866
926
|
item.enabled = false;
|
|
867
927
|
}
|
|
868
928
|
const iframes = [
|
|
@@ -877,27 +937,29 @@ class Splitview {
|
|
|
877
937
|
: event.clientY;
|
|
878
938
|
const sashIndex = firstIndex(this.sashes, (s) => s.container === sash);
|
|
879
939
|
//
|
|
880
|
-
const sizes = this.
|
|
940
|
+
const sizes = this.viewItems.map((x) => x.size);
|
|
881
941
|
//
|
|
882
942
|
let snapBefore;
|
|
883
943
|
let snapAfter;
|
|
884
944
|
const upIndexes = range(sashIndex, -1);
|
|
885
|
-
const downIndexes = range(sashIndex + 1, this.
|
|
886
|
-
const minDeltaUp = upIndexes.reduce((r, i) => r + (this.
|
|
887
|
-
const maxDeltaUp = upIndexes.reduce((r, i) => r + (this.
|
|
945
|
+
const downIndexes = range(sashIndex + 1, this.viewItems.length);
|
|
946
|
+
const minDeltaUp = upIndexes.reduce((r, i) => r + (this.viewItems[i].minimumSize - sizes[i]), 0);
|
|
947
|
+
const maxDeltaUp = upIndexes.reduce((r, i) => r + (this.viewItems[i].viewMaximumSize - sizes[i]), 0);
|
|
888
948
|
const maxDeltaDown = downIndexes.length === 0
|
|
889
949
|
? Number.POSITIVE_INFINITY
|
|
890
|
-
: downIndexes.reduce((r, i) => r +
|
|
950
|
+
: downIndexes.reduce((r, i) => r +
|
|
951
|
+
(sizes[i] - this.viewItems[i].minimumSize), 0);
|
|
891
952
|
const minDeltaDown = downIndexes.length === 0
|
|
892
953
|
? Number.NEGATIVE_INFINITY
|
|
893
954
|
: downIndexes.reduce((r, i) => r +
|
|
894
|
-
(sizes[i] -
|
|
955
|
+
(sizes[i] -
|
|
956
|
+
this.viewItems[i].viewMaximumSize), 0);
|
|
895
957
|
const minDelta = Math.max(minDeltaUp, minDeltaDown);
|
|
896
958
|
const maxDelta = Math.min(maxDeltaDown, maxDeltaUp);
|
|
897
959
|
const snapBeforeIndex = this.findFirstSnapIndex(upIndexes);
|
|
898
960
|
const snapAfterIndex = this.findFirstSnapIndex(downIndexes);
|
|
899
961
|
if (typeof snapBeforeIndex === 'number') {
|
|
900
|
-
const snappedViewItem = this.
|
|
962
|
+
const snappedViewItem = this.viewItems[snapBeforeIndex];
|
|
901
963
|
const halfSize = Math.floor(snappedViewItem.viewMinimumSize / 2);
|
|
902
964
|
snapBefore = {
|
|
903
965
|
index: snapBeforeIndex,
|
|
@@ -908,7 +970,7 @@ class Splitview {
|
|
|
908
970
|
};
|
|
909
971
|
}
|
|
910
972
|
if (typeof snapAfterIndex === 'number') {
|
|
911
|
-
const snappedViewItem = this.
|
|
973
|
+
const snappedViewItem = this.viewItems[snapAfterIndex];
|
|
912
974
|
const halfSize = Math.floor(snappedViewItem.viewMinimumSize / 2);
|
|
913
975
|
snapAfter = {
|
|
914
976
|
index: snapAfterIndex,
|
|
@@ -929,7 +991,7 @@ class Splitview {
|
|
|
929
991
|
this.layoutViews();
|
|
930
992
|
};
|
|
931
993
|
const end = () => {
|
|
932
|
-
for (const item of this.
|
|
994
|
+
for (const item of this.viewItems) {
|
|
933
995
|
item.enabled = true;
|
|
934
996
|
}
|
|
935
997
|
for (const iframe of iframes) {
|
|
@@ -969,7 +1031,7 @@ class Splitview {
|
|
|
969
1031
|
distributeViewSizes() {
|
|
970
1032
|
const flexibleViewItems = [];
|
|
971
1033
|
let flexibleSize = 0;
|
|
972
|
-
for (const item of this.
|
|
1034
|
+
for (const item of this.viewItems) {
|
|
973
1035
|
if (item.maximumSize - item.minimumSize > 0) {
|
|
974
1036
|
flexibleViewItems.push(item);
|
|
975
1037
|
flexibleSize += item.size;
|
|
@@ -979,17 +1041,17 @@ class Splitview {
|
|
|
979
1041
|
for (const item of flexibleViewItems) {
|
|
980
1042
|
item.size = clamp(size, item.minimumSize, item.maximumSize);
|
|
981
1043
|
}
|
|
982
|
-
const indexes = range(this.
|
|
983
|
-
const lowPriorityIndexes = indexes.filter((i) => this.
|
|
984
|
-
const highPriorityIndexes = indexes.filter((i) => this.
|
|
1044
|
+
const indexes = range(this.viewItems.length);
|
|
1045
|
+
const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === LayoutPriority.Low);
|
|
1046
|
+
const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === LayoutPriority.High);
|
|
985
1047
|
this.relayout(lowPriorityIndexes, highPriorityIndexes);
|
|
986
1048
|
}
|
|
987
1049
|
removeView(index, sizing, skipLayout = false) {
|
|
988
1050
|
// Remove view
|
|
989
|
-
const viewItem = this.
|
|
1051
|
+
const viewItem = this.viewItems.splice(index, 1)[0];
|
|
990
1052
|
viewItem.dispose();
|
|
991
1053
|
// Remove sash
|
|
992
|
-
if (this.
|
|
1054
|
+
if (this.viewItems.length >= 1) {
|
|
993
1055
|
const sashIndex = Math.max(index - 1, 0);
|
|
994
1056
|
const sashItem = this.sashes.splice(sashIndex, 1)[0];
|
|
995
1057
|
sashItem.disposable();
|
|
@@ -1004,10 +1066,10 @@ class Splitview {
|
|
|
1004
1066
|
return viewItem.view;
|
|
1005
1067
|
}
|
|
1006
1068
|
getViewCachedVisibleSize(index) {
|
|
1007
|
-
if (index < 0 || index >= this.
|
|
1069
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
1008
1070
|
throw new Error('Index out of bounds');
|
|
1009
1071
|
}
|
|
1010
|
-
const viewItem = this.
|
|
1072
|
+
const viewItem = this.viewItems[index];
|
|
1011
1073
|
return viewItem.cachedVisibleSize;
|
|
1012
1074
|
}
|
|
1013
1075
|
moveView(from, to) {
|
|
@@ -1023,14 +1085,14 @@ class Splitview {
|
|
|
1023
1085
|
this.size = size;
|
|
1024
1086
|
this.orthogonalSize = orthogonalSize;
|
|
1025
1087
|
if (!this.proportions) {
|
|
1026
|
-
const indexes = range(this.
|
|
1027
|
-
const lowPriorityIndexes = indexes.filter((i) => this.
|
|
1028
|
-
const highPriorityIndexes = indexes.filter((i) => this.
|
|
1029
|
-
this.resize(this.
|
|
1088
|
+
const indexes = range(this.viewItems.length);
|
|
1089
|
+
const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === LayoutPriority.Low);
|
|
1090
|
+
const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === LayoutPriority.High);
|
|
1091
|
+
this.resize(this.viewItems.length - 1, size - previousSize, undefined, lowPriorityIndexes, highPriorityIndexes);
|
|
1030
1092
|
}
|
|
1031
1093
|
else {
|
|
1032
|
-
for (let i = 0; i < this.
|
|
1033
|
-
const item = this.
|
|
1094
|
+
for (let i = 0; i < this.viewItems.length; i++) {
|
|
1095
|
+
const item = this.viewItems[i];
|
|
1034
1096
|
item.size = clamp(Math.round(this.proportions[i] * size), item.minimumSize, item.maximumSize);
|
|
1035
1097
|
}
|
|
1036
1098
|
}
|
|
@@ -1038,18 +1100,18 @@ class Splitview {
|
|
|
1038
1100
|
this.layoutViews();
|
|
1039
1101
|
}
|
|
1040
1102
|
relayout(lowPriorityIndexes, highPriorityIndexes) {
|
|
1041
|
-
const contentSize = this.
|
|
1042
|
-
this.resize(this.
|
|
1103
|
+
const contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
|
|
1104
|
+
this.resize(this.viewItems.length - 1, this._size - contentSize, undefined, lowPriorityIndexes, highPriorityIndexes);
|
|
1043
1105
|
this.distributeEmptySpace();
|
|
1044
1106
|
this.layoutViews();
|
|
1045
1107
|
this.saveProportions();
|
|
1046
1108
|
}
|
|
1047
1109
|
distributeEmptySpace(lowPriorityIndex) {
|
|
1048
|
-
const contentSize = this.
|
|
1110
|
+
const contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
|
|
1049
1111
|
let emptyDelta = this.size - contentSize;
|
|
1050
|
-
const indexes = range(this.
|
|
1051
|
-
const lowPriorityIndexes = indexes.filter((i) => this.
|
|
1052
|
-
const highPriorityIndexes = indexes.filter((i) => this.
|
|
1112
|
+
const indexes = range(this.viewItems.length - 1, -1);
|
|
1113
|
+
const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === LayoutPriority.Low);
|
|
1114
|
+
const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === LayoutPriority.High);
|
|
1053
1115
|
for (const index of highPriorityIndexes) {
|
|
1054
1116
|
pushToStart(indexes, index);
|
|
1055
1117
|
}
|
|
@@ -1060,7 +1122,7 @@ class Splitview {
|
|
|
1060
1122
|
pushToEnd(indexes, lowPriorityIndex);
|
|
1061
1123
|
}
|
|
1062
1124
|
for (let i = 0; emptyDelta !== 0 && i < indexes.length; i++) {
|
|
1063
|
-
const item = this.
|
|
1125
|
+
const item = this.viewItems[indexes[i]];
|
|
1064
1126
|
const size = clamp(item.size + emptyDelta, item.minimumSize, item.maximumSize);
|
|
1065
1127
|
const viewDelta = size - item.size;
|
|
1066
1128
|
emptyDelta -= viewDelta;
|
|
@@ -1069,16 +1131,16 @@ class Splitview {
|
|
|
1069
1131
|
}
|
|
1070
1132
|
saveProportions() {
|
|
1071
1133
|
if (this.proportionalLayout && this.contentSize > 0) {
|
|
1072
|
-
this._proportions = this.
|
|
1134
|
+
this._proportions = this.viewItems.map((i) => i.size / this.contentSize);
|
|
1073
1135
|
}
|
|
1074
1136
|
}
|
|
1075
1137
|
layoutViews() {
|
|
1076
|
-
this.contentSize = this.
|
|
1138
|
+
this.contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
|
|
1077
1139
|
let sum = 0;
|
|
1078
1140
|
const x = [];
|
|
1079
1141
|
this.updateSashEnablement();
|
|
1080
|
-
for (let i = 0; i < this.
|
|
1081
|
-
sum += this.
|
|
1142
|
+
for (let i = 0; i < this.viewItems.length - 1; i++) {
|
|
1143
|
+
sum += this.viewItems[i].size;
|
|
1082
1144
|
x.push(sum);
|
|
1083
1145
|
const offset = Math.min(Math.max(0, sum - 2), this.size - 4);
|
|
1084
1146
|
if (this._orientation === Orientation.HORIZONTAL) {
|
|
@@ -1090,7 +1152,7 @@ class Splitview {
|
|
|
1090
1152
|
this.sashes[i].container.style.top = `${offset}px`;
|
|
1091
1153
|
}
|
|
1092
1154
|
}
|
|
1093
|
-
this.
|
|
1155
|
+
this.viewItems.forEach((view, i) => {
|
|
1094
1156
|
if (this._orientation === Orientation.HORIZONTAL) {
|
|
1095
1157
|
view.container.style.width = `${view.size}px`;
|
|
1096
1158
|
view.container.style.left = i == 0 ? '0px' : `${x[i - 1]}px`;
|
|
@@ -1109,7 +1171,7 @@ class Splitview {
|
|
|
1109
1171
|
findFirstSnapIndex(indexes) {
|
|
1110
1172
|
// visible views first
|
|
1111
1173
|
for (const index of indexes) {
|
|
1112
|
-
const viewItem = this.
|
|
1174
|
+
const viewItem = this.viewItems[index];
|
|
1113
1175
|
if (!viewItem.visible) {
|
|
1114
1176
|
continue;
|
|
1115
1177
|
}
|
|
@@ -1119,7 +1181,7 @@ class Splitview {
|
|
|
1119
1181
|
}
|
|
1120
1182
|
// then, hidden views
|
|
1121
1183
|
for (const index of indexes) {
|
|
1122
|
-
const viewItem = this.
|
|
1184
|
+
const viewItem = this.viewItems[index];
|
|
1123
1185
|
if (viewItem.visible &&
|
|
1124
1186
|
viewItem.maximumSize - viewItem.minimumSize > 0) {
|
|
1125
1187
|
return undefined;
|
|
@@ -1132,10 +1194,10 @@ class Splitview {
|
|
|
1132
1194
|
}
|
|
1133
1195
|
updateSashEnablement() {
|
|
1134
1196
|
let previous = false;
|
|
1135
|
-
const collapsesDown = this.
|
|
1197
|
+
const collapsesDown = this.viewItems.map((i) => (previous = i.size - i.minimumSize > 0 || previous));
|
|
1136
1198
|
previous = false;
|
|
1137
|
-
const expandsDown = this.
|
|
1138
|
-
const reverseViews = [...this.
|
|
1199
|
+
const expandsDown = this.viewItems.map((i) => (previous = i.maximumSize - i.size > 0 || previous));
|
|
1200
|
+
const reverseViews = [...this.viewItems].reverse();
|
|
1139
1201
|
previous = false;
|
|
1140
1202
|
const collapsesUp = reverseViews
|
|
1141
1203
|
.map((i) => (previous = i.size - i.minimumSize > 0 || previous))
|
|
@@ -1147,19 +1209,19 @@ class Splitview {
|
|
|
1147
1209
|
let position = 0;
|
|
1148
1210
|
for (let index = 0; index < this.sashes.length; index++) {
|
|
1149
1211
|
const sash = this.sashes[index];
|
|
1150
|
-
const viewItem = this.
|
|
1212
|
+
const viewItem = this.viewItems[index];
|
|
1151
1213
|
position += viewItem.size;
|
|
1152
1214
|
const min = !(collapsesDown[index] && expandsUp[index + 1]);
|
|
1153
1215
|
const max = !(expandsDown[index] && collapsesUp[index + 1]);
|
|
1154
1216
|
if (min && max) {
|
|
1155
1217
|
const upIndexes = range(index, -1);
|
|
1156
|
-
const downIndexes = range(index + 1, this.
|
|
1218
|
+
const downIndexes = range(index + 1, this.viewItems.length);
|
|
1157
1219
|
const snapBeforeIndex = this.findFirstSnapIndex(upIndexes);
|
|
1158
1220
|
const snapAfterIndex = this.findFirstSnapIndex(downIndexes);
|
|
1159
1221
|
const snappedBefore = typeof snapBeforeIndex === 'number' &&
|
|
1160
|
-
!this.
|
|
1222
|
+
!this.viewItems[snapBeforeIndex].visible;
|
|
1161
1223
|
const snappedAfter = typeof snapAfterIndex === 'number' &&
|
|
1162
|
-
!this.
|
|
1224
|
+
!this.viewItems[snapAfterIndex].visible;
|
|
1163
1225
|
if (snappedBefore &&
|
|
1164
1226
|
collapsesUp[index] &&
|
|
1165
1227
|
(position > 0 || this.startSnappingEnabled)) {
|
|
@@ -1219,6 +1281,9 @@ class Splitview {
|
|
|
1219
1281
|
break;
|
|
1220
1282
|
}
|
|
1221
1283
|
}
|
|
1284
|
+
for (const viewItem of this.viewItems) {
|
|
1285
|
+
viewItem.dispose();
|
|
1286
|
+
}
|
|
1222
1287
|
this.element.remove();
|
|
1223
1288
|
}
|
|
1224
1289
|
}
|
|
@@ -1653,7 +1718,7 @@ class BranchNode extends CompositeDisposable {
|
|
|
1653
1718
|
throw new Error('Invalid index');
|
|
1654
1719
|
}
|
|
1655
1720
|
this.splitview.removeView(index, sizing);
|
|
1656
|
-
this._removeChild(index);
|
|
1721
|
+
return this._removeChild(index);
|
|
1657
1722
|
}
|
|
1658
1723
|
_addChild(node, index) {
|
|
1659
1724
|
this.children.splice(index, 0, node);
|
|
@@ -1675,10 +1740,10 @@ class BranchNode extends CompositeDisposable {
|
|
|
1675
1740
|
});
|
|
1676
1741
|
}
|
|
1677
1742
|
dispose() {
|
|
1678
|
-
super.dispose();
|
|
1679
1743
|
this._childrenDisposable.dispose();
|
|
1680
|
-
this.children.forEach((child) => child.dispose());
|
|
1681
1744
|
this.splitview.dispose();
|
|
1745
|
+
this.children.forEach((child) => child.dispose());
|
|
1746
|
+
super.dispose();
|
|
1682
1747
|
}
|
|
1683
1748
|
}
|
|
1684
1749
|
|
|
@@ -1908,7 +1973,8 @@ class Gridview {
|
|
|
1908
1973
|
if (oldRoot.children.length === 1) {
|
|
1909
1974
|
// can remove one level of redundant branching if there is only a single child
|
|
1910
1975
|
const childReference = oldRoot.children[0];
|
|
1911
|
-
oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
|
|
1976
|
+
const child = oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
|
|
1977
|
+
child.dispose();
|
|
1912
1978
|
oldRoot.dispose();
|
|
1913
1979
|
this._root.addChild(
|
|
1914
1980
|
/**
|
|
@@ -2015,7 +2081,8 @@ class Gridview {
|
|
|
2015
2081
|
if (typeof newSiblingCachedVisibleSize === 'number') {
|
|
2016
2082
|
newSiblingSize = Sizing.Invisible(newSiblingCachedVisibleSize);
|
|
2017
2083
|
}
|
|
2018
|
-
grandParent.removeChild(parentIndex);
|
|
2084
|
+
const child = grandParent.removeChild(parentIndex);
|
|
2085
|
+
child.dispose();
|
|
2019
2086
|
const newParent = new BranchNode(parent.orientation, this.proportionalLayout, this.styles, parent.size, parent.orthogonalSize);
|
|
2020
2087
|
grandParent.addChild(newParent, parent.size, parentIndex);
|
|
2021
2088
|
const newSibling = new LeafNode(parent.view, grandParent.orientation, parent.size);
|
|
@@ -2041,30 +2108,36 @@ class Gridview {
|
|
|
2041
2108
|
if (!(node instanceof LeafNode)) {
|
|
2042
2109
|
throw new Error('Invalid location');
|
|
2043
2110
|
}
|
|
2044
|
-
|
|
2111
|
+
const view = node.view;
|
|
2112
|
+
node.dispose(); // dispose of node
|
|
2113
|
+
const child = parent.removeChild(index, sizing);
|
|
2114
|
+
child.dispose();
|
|
2045
2115
|
if (parent.children.length === 0) {
|
|
2046
|
-
return
|
|
2116
|
+
return view;
|
|
2047
2117
|
}
|
|
2048
2118
|
if (parent.children.length > 1) {
|
|
2049
|
-
return
|
|
2119
|
+
return view;
|
|
2050
2120
|
}
|
|
2051
2121
|
const sibling = parent.children[0];
|
|
2052
2122
|
if (pathToParent.length === 0) {
|
|
2053
2123
|
// parent is root
|
|
2054
2124
|
if (sibling instanceof LeafNode) {
|
|
2055
|
-
return
|
|
2125
|
+
return view;
|
|
2056
2126
|
}
|
|
2057
2127
|
// we must promote sibling to be the new root
|
|
2058
|
-
parent.removeChild(0, sizing);
|
|
2128
|
+
const child = parent.removeChild(0, sizing);
|
|
2129
|
+
child.dispose();
|
|
2059
2130
|
this.root = sibling;
|
|
2060
|
-
return
|
|
2131
|
+
return view;
|
|
2061
2132
|
}
|
|
2062
2133
|
const [grandParent, ..._] = [...pathToParent].reverse();
|
|
2063
2134
|
const [parentIndex, ...__] = [...rest].reverse();
|
|
2064
2135
|
const isSiblingVisible = parent.isChildVisible(0);
|
|
2065
|
-
parent.removeChild(0, sizing);
|
|
2136
|
+
const childNode = parent.removeChild(0, sizing);
|
|
2137
|
+
childNode.dispose();
|
|
2066
2138
|
const sizes = grandParent.children.map((_size, i) => grandParent.getChildSize(i));
|
|
2067
|
-
grandParent.removeChild(parentIndex, sizing);
|
|
2139
|
+
const parentNode = grandParent.removeChild(parentIndex, sizing);
|
|
2140
|
+
parentNode.dispose();
|
|
2068
2141
|
if (sibling instanceof BranchNode) {
|
|
2069
2142
|
sizes.splice(parentIndex, 1, ...sibling.children.map((c) => c.size));
|
|
2070
2143
|
for (let i = 0; i < sibling.children.length; i++) {
|
|
@@ -2082,7 +2155,7 @@ class Gridview {
|
|
|
2082
2155
|
for (let i = 0; i < sizes.length; i++) {
|
|
2083
2156
|
grandParent.resizeChild(i, sizes[i]);
|
|
2084
2157
|
}
|
|
2085
|
-
return
|
|
2158
|
+
return view;
|
|
2086
2159
|
}
|
|
2087
2160
|
layout(width, height) {
|
|
2088
2161
|
const [size, orthogonalSize] = this.root.orientation === Orientation.HORIZONTAL
|
|
@@ -2577,6 +2650,7 @@ class Droptarget extends CompositeDisposable {
|
|
|
2577
2650
|
}
|
|
2578
2651
|
dispose() {
|
|
2579
2652
|
this.removeDropTarget();
|
|
2653
|
+
super.dispose();
|
|
2580
2654
|
}
|
|
2581
2655
|
toggleClasses(quadrant, width, height) {
|
|
2582
2656
|
var _a, _b, _c, _d;
|
|
@@ -2754,8 +2828,8 @@ class ContentContainer extends CompositeDisposable {
|
|
|
2754
2828
|
if (this.panel.view) {
|
|
2755
2829
|
const _onDidFocus = this.panel.view.content.onDidFocus;
|
|
2756
2830
|
const _onDidBlur = this.panel.view.content.onDidBlur;
|
|
2757
|
-
const
|
|
2758
|
-
disposable.addDisposables(onDidFocus(() => this._onDidFocus.fire()), onDidBlur(() => this._onDidBlur.fire()));
|
|
2831
|
+
const focusTracker = trackFocus(this._element);
|
|
2832
|
+
disposable.addDisposables(focusTracker, focusTracker.onDidFocus(() => this._onDidFocus.fire()), focusTracker.onDidBlur(() => this._onDidBlur.fire()));
|
|
2759
2833
|
if (_onDidFocus) {
|
|
2760
2834
|
disposable.addDisposables(_onDidFocus(() => this._onDidFocus.fire()));
|
|
2761
2835
|
}
|
|
@@ -2798,6 +2872,7 @@ class DragHandler extends CompositeDisposable {
|
|
|
2798
2872
|
this._onDragStart = new Emitter();
|
|
2799
2873
|
this.onDragStart = this._onDragStart.event;
|
|
2800
2874
|
this.iframes = [];
|
|
2875
|
+
this.addDisposables(this._onDragStart);
|
|
2801
2876
|
this.configure();
|
|
2802
2877
|
}
|
|
2803
2878
|
configure() {
|
|
@@ -2848,13 +2923,12 @@ class Tab extends CompositeDisposable {
|
|
|
2848
2923
|
this.onChanged = this._onChanged.event;
|
|
2849
2924
|
this._onDropped = new Emitter();
|
|
2850
2925
|
this.onDrop = this._onDropped.event;
|
|
2851
|
-
this.addDisposables(this._onChanged, this._onDropped);
|
|
2852
2926
|
this._element = document.createElement('div');
|
|
2853
2927
|
this._element.className = 'tab';
|
|
2854
2928
|
this._element.tabIndex = 0;
|
|
2855
2929
|
this._element.draggable = true;
|
|
2856
2930
|
toggleClass(this.element, 'inactive-tab', true);
|
|
2857
|
-
this.addDisposables(new (class Handler extends DragHandler {
|
|
2931
|
+
this.addDisposables(this._onChanged, this._onDropped, new (class Handler extends DragHandler {
|
|
2858
2932
|
constructor() {
|
|
2859
2933
|
super(...arguments);
|
|
2860
2934
|
this.panelTransfer = LocalSelectionTransfer.getInstance();
|
|
@@ -2867,9 +2941,6 @@ class Tab extends CompositeDisposable {
|
|
|
2867
2941
|
},
|
|
2868
2942
|
};
|
|
2869
2943
|
}
|
|
2870
|
-
dispose() {
|
|
2871
|
-
//
|
|
2872
|
-
}
|
|
2873
2944
|
})(this._element));
|
|
2874
2945
|
this.addDisposables(addDisposableListener(this._element, 'mousedown', (event) => {
|
|
2875
2946
|
if (event.defaultPrevented) {
|
|
@@ -2904,7 +2975,7 @@ class Tab extends CompositeDisposable {
|
|
|
2904
2975
|
});
|
|
2905
2976
|
this.addDisposables(this.droptarget.onDrop((event) => {
|
|
2906
2977
|
this._onDropped.fire(event);
|
|
2907
|
-
}));
|
|
2978
|
+
}), this.droptarget);
|
|
2908
2979
|
}
|
|
2909
2980
|
setActive(isActive) {
|
|
2910
2981
|
toggleClass(this.element, 'active-tab', isActive);
|
|
@@ -2919,7 +2990,6 @@ class Tab extends CompositeDisposable {
|
|
|
2919
2990
|
}
|
|
2920
2991
|
dispose() {
|
|
2921
2992
|
super.dispose();
|
|
2922
|
-
this.droptarget.dispose();
|
|
2923
2993
|
}
|
|
2924
2994
|
}
|
|
2925
2995
|
|
|
@@ -2965,9 +3035,6 @@ class GroupDragHandler extends DragHandler {
|
|
|
2965
3035
|
},
|
|
2966
3036
|
};
|
|
2967
3037
|
}
|
|
2968
|
-
dispose() {
|
|
2969
|
-
//
|
|
2970
|
-
}
|
|
2971
3038
|
}
|
|
2972
3039
|
|
|
2973
3040
|
class VoidContainer extends CompositeDisposable {
|
|
@@ -3123,6 +3190,7 @@ class TabsContainer extends CompositeDisposable {
|
|
|
3123
3190
|
const tabToRemove = this.tabs.splice(index, 1)[0];
|
|
3124
3191
|
const { value, disposable } = tabToRemove;
|
|
3125
3192
|
disposable.dispose();
|
|
3193
|
+
value.dispose();
|
|
3126
3194
|
value.element.remove();
|
|
3127
3195
|
}
|
|
3128
3196
|
setActivePanel(panel) {
|
|
@@ -3166,9 +3234,10 @@ class TabsContainer extends CompositeDisposable {
|
|
|
3166
3234
|
}
|
|
3167
3235
|
dispose() {
|
|
3168
3236
|
super.dispose();
|
|
3169
|
-
this.tabs
|
|
3170
|
-
|
|
3171
|
-
|
|
3237
|
+
for (const { value, disposable } of this.tabs) {
|
|
3238
|
+
disposable.dispose();
|
|
3239
|
+
value.dispose();
|
|
3240
|
+
}
|
|
3172
3241
|
this.tabs = [];
|
|
3173
3242
|
}
|
|
3174
3243
|
}
|
|
@@ -3266,7 +3335,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
|
|
|
3266
3335
|
container.append(this.tabsContainer.element, this.contentContainer.element);
|
|
3267
3336
|
this.header.hidden = !!options.hideHeader;
|
|
3268
3337
|
this.locked = !!options.locked;
|
|
3269
|
-
this.addDisposables(this.
|
|
3338
|
+
this.addDisposables(this.tabsContainer.onDrop((event) => {
|
|
3270
3339
|
this.handleDropEvent(event.event, 'center', event.index);
|
|
3271
3340
|
}), this.contentContainer.onDidFocus(() => {
|
|
3272
3341
|
this.accessor.doSetGroupActive(this.groupPanel, true);
|
|
@@ -3274,7 +3343,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
|
|
|
3274
3343
|
// noop
|
|
3275
3344
|
}), this.dropTarget.onDrop((event) => {
|
|
3276
3345
|
this.handleDropEvent(event.nativeEvent, event.position);
|
|
3277
|
-
}));
|
|
3346
|
+
}), this._onMove, this._onDidChange, this._onDidDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange);
|
|
3278
3347
|
}
|
|
3279
3348
|
initialize() {
|
|
3280
3349
|
var _a, _b;
|
|
@@ -3708,8 +3777,7 @@ class BaseGrid extends Resizable {
|
|
|
3708
3777
|
this.layout(0, 0, true); // set some elements height/widths
|
|
3709
3778
|
this.addDisposables(this.gridview.onDidChange(() => {
|
|
3710
3779
|
this._bufferOnDidLayoutChange.fire();
|
|
3711
|
-
}))
|
|
3712
|
-
this.addDisposables(Event.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
|
|
3780
|
+
}), Event.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
|
|
3713
3781
|
this._bufferOnDidLayoutChange.fire();
|
|
3714
3782
|
}), this._bufferOnDidLayoutChange.onEvent(() => {
|
|
3715
3783
|
this._onDidLayoutChange.fire();
|
|
@@ -3812,7 +3880,6 @@ class BaseGrid extends Resizable {
|
|
|
3812
3880
|
this.gridview.layout(width, height);
|
|
3813
3881
|
}
|
|
3814
3882
|
dispose() {
|
|
3815
|
-
super.dispose();
|
|
3816
3883
|
this._onDidActiveGroupChange.dispose();
|
|
3817
3884
|
this._onDidAddGroup.dispose();
|
|
3818
3885
|
this._onDidRemoveGroup.dispose();
|
|
@@ -3821,6 +3888,7 @@ class BaseGrid extends Resizable {
|
|
|
3821
3888
|
group.dispose();
|
|
3822
3889
|
}
|
|
3823
3890
|
this.gridview.dispose();
|
|
3891
|
+
super.dispose();
|
|
3824
3892
|
}
|
|
3825
3893
|
}
|
|
3826
3894
|
|
|
@@ -3884,7 +3952,7 @@ class PanelApiImpl extends CompositeDisposable {
|
|
|
3884
3952
|
//
|
|
3885
3953
|
this._onUpdateParameters = new Emitter();
|
|
3886
3954
|
this.onUpdateParameters = this._onUpdateParameters.event;
|
|
3887
|
-
this.addDisposables(this.
|
|
3955
|
+
this.addDisposables(this.onDidFocusChange((event) => {
|
|
3888
3956
|
this._isFocused = event.isFocused;
|
|
3889
3957
|
}), this.onDidActiveChange((event) => {
|
|
3890
3958
|
this._isActive = event.isActive;
|
|
@@ -3893,14 +3961,12 @@ class PanelApiImpl extends CompositeDisposable {
|
|
|
3893
3961
|
}), this.onDidDimensionsChange((event) => {
|
|
3894
3962
|
this._width = event.width;
|
|
3895
3963
|
this._height = event.height;
|
|
3896
|
-
}));
|
|
3964
|
+
}), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onFocusEvent, this._onActiveChange, this._onVisibilityChange, this._onUpdateParameters);
|
|
3897
3965
|
}
|
|
3898
3966
|
initialize(panel) {
|
|
3899
3967
|
this.panelUpdatesDisposable.value = this._onUpdateParameters.event((parameters) => {
|
|
3900
3968
|
panel.update({
|
|
3901
|
-
params:
|
|
3902
|
-
params: parameters,
|
|
3903
|
-
},
|
|
3969
|
+
params: parameters,
|
|
3904
3970
|
});
|
|
3905
3971
|
});
|
|
3906
3972
|
}
|
|
@@ -3995,12 +4061,12 @@ class BasePanelView extends CompositeDisposable {
|
|
|
3995
4061
|
this._element.style.height = '100%';
|
|
3996
4062
|
this._element.style.width = '100%';
|
|
3997
4063
|
this._element.style.overflow = 'hidden';
|
|
3998
|
-
const
|
|
3999
|
-
this.addDisposables(this.api, onDidFocus(() => {
|
|
4064
|
+
const focusTracker = trackFocus(this._element);
|
|
4065
|
+
this.addDisposables(this.api, focusTracker.onDidFocus(() => {
|
|
4000
4066
|
this.api._onDidChangeFocus.fire({ isFocused: true });
|
|
4001
|
-
}), onDidBlur(() => {
|
|
4067
|
+
}), focusTracker.onDidBlur(() => {
|
|
4002
4068
|
this.api._onDidChangeFocus.fire({ isFocused: false });
|
|
4003
|
-
}));
|
|
4069
|
+
}), focusTracker);
|
|
4004
4070
|
}
|
|
4005
4071
|
focus() {
|
|
4006
4072
|
this.api._onFocusEvent.fire();
|
|
@@ -4021,7 +4087,18 @@ class BasePanelView extends CompositeDisposable {
|
|
|
4021
4087
|
}
|
|
4022
4088
|
update(event) {
|
|
4023
4089
|
var _a, _b;
|
|
4090
|
+
// merge the new parameters with the existing parameters
|
|
4024
4091
|
this._params = Object.assign(Object.assign({}, this._params), { params: Object.assign(Object.assign({}, (_a = this._params) === null || _a === void 0 ? void 0 : _a.params), event.params) });
|
|
4092
|
+
/**
|
|
4093
|
+
* delete new keys that have a value of undefined,
|
|
4094
|
+
* allow values of null
|
|
4095
|
+
*/
|
|
4096
|
+
for (const key of Object.keys(event.params)) {
|
|
4097
|
+
if (event.params[key] === undefined) {
|
|
4098
|
+
delete this._params.params[key];
|
|
4099
|
+
}
|
|
4100
|
+
}
|
|
4101
|
+
// update the view with the updated props
|
|
4025
4102
|
(_b = this.part) === null || _b === void 0 ? void 0 : _b.update({ params: this._params.params });
|
|
4026
4103
|
}
|
|
4027
4104
|
toJSON() {
|
|
@@ -4035,9 +4112,9 @@ class BasePanelView extends CompositeDisposable {
|
|
|
4035
4112
|
}
|
|
4036
4113
|
dispose() {
|
|
4037
4114
|
var _a;
|
|
4038
|
-
super.dispose();
|
|
4039
4115
|
this.api.dispose();
|
|
4040
4116
|
(_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
4117
|
+
super.dispose();
|
|
4041
4118
|
}
|
|
4042
4119
|
}
|
|
4043
4120
|
|
|
@@ -4416,7 +4493,7 @@ class GridviewPanel extends BasePanelView {
|
|
|
4416
4493
|
this._maximumHeight = options.maximumHeight;
|
|
4417
4494
|
}
|
|
4418
4495
|
this.api.initialize(this); // TODO: required to by-pass 'super before this' requirement
|
|
4419
|
-
this.addDisposables(this.
|
|
4496
|
+
this.addDisposables(this.api.onVisibilityChange((event) => {
|
|
4420
4497
|
const { isVisible } = event;
|
|
4421
4498
|
const { accessor } = this._params;
|
|
4422
4499
|
accessor.setVisible(this, isVisible);
|
|
@@ -4445,7 +4522,7 @@ class GridviewPanel extends BasePanelView {
|
|
|
4445
4522
|
height: event.height,
|
|
4446
4523
|
width: event.width,
|
|
4447
4524
|
});
|
|
4448
|
-
}));
|
|
4525
|
+
}), this._onDidChange);
|
|
4449
4526
|
}
|
|
4450
4527
|
setVisible(isVisible) {
|
|
4451
4528
|
this.api._onDidVisibilityChange.fire({ isVisible });
|
|
@@ -4602,7 +4679,7 @@ class DockviewPanelApiImpl extends GridviewPanelApiImpl {
|
|
|
4602
4679
|
this.addDisposables(this.disposable, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange);
|
|
4603
4680
|
}
|
|
4604
4681
|
setTitle(title) {
|
|
4605
|
-
this.panel.
|
|
4682
|
+
this.panel.setTitle(title);
|
|
4606
4683
|
}
|
|
4607
4684
|
close() {
|
|
4608
4685
|
this.group.model.closePanel(this.panel);
|
|
@@ -4667,12 +4744,18 @@ class DockviewPanel extends CompositeDisposable {
|
|
|
4667
4744
|
}
|
|
4668
4745
|
}
|
|
4669
4746
|
update(event) {
|
|
4670
|
-
|
|
4671
|
-
this._params = Object.assign(Object.assign({}, (this._params || {})), event.params
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4747
|
+
// merge the new parameters with the existing parameters
|
|
4748
|
+
this._params = Object.assign(Object.assign({}, (this._params || {})), event.params);
|
|
4749
|
+
/**
|
|
4750
|
+
* delete new keys that have a value of undefined,
|
|
4751
|
+
* allow values of null
|
|
4752
|
+
*/
|
|
4753
|
+
for (const key of Object.keys(event.params)) {
|
|
4754
|
+
if (event.params[key] === undefined) {
|
|
4755
|
+
delete this._params[key];
|
|
4756
|
+
}
|
|
4675
4757
|
}
|
|
4758
|
+
// update the view with the updated props
|
|
4676
4759
|
this.view.update({
|
|
4677
4760
|
params: {
|
|
4678
4761
|
params: this._params,
|
|
@@ -5048,7 +5131,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
5048
5131
|
size: { type: 'pixels', value: 20 },
|
|
5049
5132
|
},
|
|
5050
5133
|
});
|
|
5051
|
-
this.addDisposables(dropTarget
|
|
5134
|
+
this.addDisposables(dropTarget.onDrop((event) => {
|
|
5052
5135
|
const data = getPanelData();
|
|
5053
5136
|
if (data) {
|
|
5054
5137
|
this.moveGroupOrPanel(this.orthogonalize(event.position), data.groupId, data.panelId || undefined, 'center');
|
|
@@ -5056,7 +5139,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
5056
5139
|
else {
|
|
5057
5140
|
this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api, group: null, getData: getPanelData }));
|
|
5058
5141
|
}
|
|
5059
|
-
}));
|
|
5142
|
+
}), dropTarget);
|
|
5060
5143
|
this._api = new DockviewApi(this);
|
|
5061
5144
|
this.updateWatermark();
|
|
5062
5145
|
}
|
|
@@ -5380,31 +5463,33 @@ class DockviewComponent extends BaseGrid {
|
|
|
5380
5463
|
}
|
|
5381
5464
|
super.doRemoveGroup(group, { skipActive });
|
|
5382
5465
|
}
|
|
5383
|
-
moveGroupOrPanel(
|
|
5466
|
+
moveGroupOrPanel(destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
|
|
5384
5467
|
var _a;
|
|
5385
|
-
const sourceGroup =
|
|
5386
|
-
? (_a = this._groups.get(
|
|
5468
|
+
const sourceGroup = sourceGroupId
|
|
5469
|
+
? (_a = this._groups.get(sourceGroupId)) === null || _a === void 0 ? void 0 : _a.value
|
|
5387
5470
|
: undefined;
|
|
5388
|
-
if (
|
|
5471
|
+
if (sourceItemId === undefined) {
|
|
5389
5472
|
if (sourceGroup) {
|
|
5390
|
-
this.moveGroup(sourceGroup,
|
|
5473
|
+
this.moveGroup(sourceGroup, destinationGroup, destinationTarget);
|
|
5391
5474
|
}
|
|
5392
5475
|
return;
|
|
5393
5476
|
}
|
|
5394
|
-
if (!
|
|
5395
|
-
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(
|
|
5396
|
-
this.panels.find((panel) => panel.id ===
|
|
5477
|
+
if (!destinationTarget || destinationTarget === 'center') {
|
|
5478
|
+
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
|
|
5479
|
+
this.panels.find((panel) => panel.id === sourceItemId);
|
|
5397
5480
|
if (!groupItem) {
|
|
5398
|
-
throw new Error(`No panel with id ${
|
|
5481
|
+
throw new Error(`No panel with id ${sourceItemId}`);
|
|
5399
5482
|
}
|
|
5400
5483
|
if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
|
|
5401
5484
|
this.doRemoveGroup(sourceGroup);
|
|
5402
5485
|
}
|
|
5403
|
-
|
|
5486
|
+
destinationGroup.model.openPanel(groupItem, {
|
|
5487
|
+
index: destinationIndex,
|
|
5488
|
+
});
|
|
5404
5489
|
}
|
|
5405
5490
|
else {
|
|
5406
|
-
const referenceLocation = getGridLocation(
|
|
5407
|
-
const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation,
|
|
5491
|
+
const referenceLocation = getGridLocation(destinationGroup.element);
|
|
5492
|
+
const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
|
|
5408
5493
|
if (sourceGroup && sourceGroup.size < 2) {
|
|
5409
5494
|
const [targetParentLocation, to] = tail(targetLocation);
|
|
5410
5495
|
const sourceLocation = getGridLocation(sourceGroup.element);
|
|
@@ -5422,18 +5507,18 @@ class DockviewComponent extends BaseGrid {
|
|
|
5422
5507
|
skipDispose: true,
|
|
5423
5508
|
});
|
|
5424
5509
|
// after deleting the group we need to re-evaulate the ref location
|
|
5425
|
-
const updatedReferenceLocation = getGridLocation(
|
|
5426
|
-
const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation,
|
|
5510
|
+
const updatedReferenceLocation = getGridLocation(destinationGroup.element);
|
|
5511
|
+
const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
|
|
5427
5512
|
this.doAddGroup(targetGroup, location);
|
|
5428
5513
|
}
|
|
5429
5514
|
}
|
|
5430
5515
|
else {
|
|
5431
|
-
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(
|
|
5432
|
-
this.panels.find((panel) => panel.id ===
|
|
5516
|
+
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
|
|
5517
|
+
this.panels.find((panel) => panel.id === sourceItemId);
|
|
5433
5518
|
if (!groupItem) {
|
|
5434
|
-
throw new Error(`No panel with id ${
|
|
5519
|
+
throw new Error(`No panel with id ${sourceItemId}`);
|
|
5435
5520
|
}
|
|
5436
|
-
const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation,
|
|
5521
|
+
const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
|
|
5437
5522
|
const group = this.createGroupAtLocation(dropLocation);
|
|
5438
5523
|
group.model.openPanel(groupItem);
|
|
5439
5524
|
}
|
|
@@ -5527,11 +5612,11 @@ class DockviewComponent extends BaseGrid {
|
|
|
5527
5612
|
return (_a = Array.from(this._groups.values()).find((group) => group.value.model.containsPanel(panel))) === null || _a === void 0 ? void 0 : _a.value;
|
|
5528
5613
|
}
|
|
5529
5614
|
dispose() {
|
|
5530
|
-
super.dispose();
|
|
5531
5615
|
this._onDidActivePanelChange.dispose();
|
|
5532
5616
|
this._onDidAddPanel.dispose();
|
|
5533
5617
|
this._onDidRemovePanel.dispose();
|
|
5534
5618
|
this._onDidLayoutFromJSON.dispose();
|
|
5619
|
+
super.dispose();
|
|
5535
5620
|
}
|
|
5536
5621
|
}
|
|
5537
5622
|
|
|
@@ -5789,7 +5874,7 @@ class SplitviewComponent extends Resizable {
|
|
|
5789
5874
|
}
|
|
5790
5875
|
set splitview(value) {
|
|
5791
5876
|
this._splitview = value;
|
|
5792
|
-
this.
|
|
5877
|
+
this._splitviewChangeDisposable.value = new CompositeDisposable(this._splitview.onDidSashEnd(() => {
|
|
5793
5878
|
this._onDidLayoutChange.fire(undefined);
|
|
5794
5879
|
}), this._splitview.onDidAddView((e) => this._onDidAddView.fire(e)), this._splitview.onDidRemoveView((e) => this._onDidRemoveView.fire(e)));
|
|
5795
5880
|
}
|
|
@@ -5811,7 +5896,7 @@ class SplitviewComponent extends Resizable {
|
|
|
5811
5896
|
}
|
|
5812
5897
|
constructor(options) {
|
|
5813
5898
|
super(options.parentElement);
|
|
5814
|
-
this.
|
|
5899
|
+
this._splitviewChangeDisposable = new MutableDisposable();
|
|
5815
5900
|
this._panels = new Map();
|
|
5816
5901
|
this._onDidLayoutfromJSON = new Emitter();
|
|
5817
5902
|
this.onDidLayoutFromJSON = this._onDidLayoutfromJSON.event;
|
|
@@ -5829,7 +5914,7 @@ class SplitviewComponent extends Resizable {
|
|
|
5829
5914
|
options.frameworkComponents = {};
|
|
5830
5915
|
}
|
|
5831
5916
|
this.splitview = new Splitview(this.element, options);
|
|
5832
|
-
this.addDisposables(this.
|
|
5917
|
+
this.addDisposables(this._onDidAddView, this._onDidLayoutfromJSON, this._onDidRemoveView, this._onDidLayoutChange);
|
|
5833
5918
|
}
|
|
5834
5919
|
updateOptions(options) {
|
|
5835
5920
|
const hasOrientationChanged = typeof options.orientation === 'string' &&
|
|
@@ -5867,15 +5952,15 @@ class SplitviewComponent extends Resizable {
|
|
|
5867
5952
|
}
|
|
5868
5953
|
}
|
|
5869
5954
|
removePanel(panel, sizing) {
|
|
5870
|
-
const
|
|
5871
|
-
if (!
|
|
5955
|
+
const item = this._panels.get(panel.id);
|
|
5956
|
+
if (!item) {
|
|
5872
5957
|
throw new Error(`unknown splitview panel ${panel.id}`);
|
|
5873
5958
|
}
|
|
5874
|
-
|
|
5875
|
-
disposable.value.dispose();
|
|
5959
|
+
item.dispose();
|
|
5876
5960
|
this._panels.delete(panel.id);
|
|
5877
5961
|
const index = this.panels.findIndex((_) => _ === panel);
|
|
5878
|
-
this.splitview.removeView(index, sizing);
|
|
5962
|
+
const removedView = this.splitview.removeView(index, sizing);
|
|
5963
|
+
removedView.dispose();
|
|
5879
5964
|
const panels = this.panels;
|
|
5880
5965
|
if (panels.length > 0) {
|
|
5881
5966
|
this.setActive(panels[panels.length - 1]);
|
|
@@ -5922,7 +6007,7 @@ class SplitviewComponent extends Resizable {
|
|
|
5922
6007
|
}
|
|
5923
6008
|
this.setActive(view, true);
|
|
5924
6009
|
});
|
|
5925
|
-
this._panels.set(view.id,
|
|
6010
|
+
this._panels.set(view.id, disposable);
|
|
5926
6011
|
}
|
|
5927
6012
|
toJSON() {
|
|
5928
6013
|
var _a;
|
|
@@ -5995,20 +6080,26 @@ class SplitviewComponent extends Resizable {
|
|
|
5995
6080
|
this._onDidLayoutfromJSON.fire();
|
|
5996
6081
|
}
|
|
5997
6082
|
clear() {
|
|
5998
|
-
for (const
|
|
5999
|
-
|
|
6000
|
-
value.value.dispose();
|
|
6083
|
+
for (const disposable of this._panels.values()) {
|
|
6084
|
+
disposable.dispose();
|
|
6001
6085
|
}
|
|
6002
6086
|
this._panels.clear();
|
|
6003
|
-
this.splitview.
|
|
6087
|
+
while (this.splitview.length > 0) {
|
|
6088
|
+
const view = this.splitview.removeView(0, Sizing.Distribute, true);
|
|
6089
|
+
view.dispose();
|
|
6090
|
+
}
|
|
6004
6091
|
}
|
|
6005
6092
|
dispose() {
|
|
6006
|
-
for (const
|
|
6007
|
-
|
|
6008
|
-
value.value.dispose();
|
|
6093
|
+
for (const disposable of this._panels.values()) {
|
|
6094
|
+
disposable.dispose();
|
|
6009
6095
|
}
|
|
6010
6096
|
this._panels.clear();
|
|
6097
|
+
const views = this.splitview.getViews();
|
|
6098
|
+
this._splitviewChangeDisposable.dispose();
|
|
6011
6099
|
this.splitview.dispose();
|
|
6100
|
+
for (const view of views) {
|
|
6101
|
+
view.dispose();
|
|
6102
|
+
}
|
|
6012
6103
|
super.dispose();
|
|
6013
6104
|
}
|
|
6014
6105
|
}
|