dockview 1.7.3 → 1.7.5
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 +281 -194
- package/dist/dockview.amd.min.js +2 -2
- package/dist/dockview.amd.min.noStyle.js +2 -2
- package/dist/dockview.amd.noStyle.js +281 -194
- package/dist/dockview.cjs.js +281 -194
- package/dist/dockview.esm.js +281 -194
- package/dist/dockview.esm.min.js +2 -2
- package/dist/dockview.js +281 -194
- package/dist/dockview.min.js +2 -2
- package/dist/dockview.min.noStyle.js +2 -2
- package/dist/dockview.noStyle.js +281 -194
- package/package.json +3 -3
package/dist/dockview.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dockview
|
|
3
|
-
* @version 1.7.
|
|
3
|
+
* @version 1.7.5
|
|
4
4
|
* @link https://github.com/mathuo/dockview
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
@@ -144,9 +144,49 @@ exports.DockviewEvent = void 0;
|
|
|
144
144
|
};
|
|
145
145
|
};
|
|
146
146
|
})(exports.DockviewEvent || (exports.DockviewEvent = {}));
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
class LeakageMonitor {
|
|
148
|
+
constructor() {
|
|
149
|
+
this.events = new Map();
|
|
150
|
+
}
|
|
151
|
+
get size() {
|
|
152
|
+
return this.events.size;
|
|
153
|
+
}
|
|
154
|
+
add(event, stacktrace) {
|
|
155
|
+
this.events.set(event, stacktrace);
|
|
156
|
+
}
|
|
157
|
+
delete(event) {
|
|
158
|
+
this.events.delete(event);
|
|
159
|
+
}
|
|
160
|
+
clear() {
|
|
161
|
+
this.events.clear();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
class Stacktrace {
|
|
165
|
+
static create() {
|
|
166
|
+
var _a;
|
|
167
|
+
return new Stacktrace((_a = new Error().stack) !== null && _a !== void 0 ? _a : '');
|
|
168
|
+
}
|
|
169
|
+
constructor(value) {
|
|
170
|
+
this.value = value;
|
|
171
|
+
}
|
|
172
|
+
print() {
|
|
173
|
+
console.warn(this.value);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
class Listener {
|
|
177
|
+
constructor(callback, stacktrace) {
|
|
178
|
+
this.callback = callback;
|
|
179
|
+
this.stacktrace = stacktrace;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// relatively simple event emitter taken from https://github.com/microsoft/vscode/blob/master/src/vs/base/common/event.ts
|
|
149
183
|
class Emitter {
|
|
184
|
+
static setLeakageMonitorEnabled(isEnabled) {
|
|
185
|
+
if (isEnabled !== Emitter.ENABLE_TRACKING) {
|
|
186
|
+
Emitter.MEMORY_LEAK_WATCHER.clear();
|
|
187
|
+
}
|
|
188
|
+
Emitter.ENABLE_TRACKING = isEnabled;
|
|
189
|
+
}
|
|
150
190
|
constructor(options) {
|
|
151
191
|
this.options = options;
|
|
152
192
|
this._listeners = [];
|
|
@@ -154,11 +194,12 @@ class Emitter {
|
|
|
154
194
|
}
|
|
155
195
|
get event() {
|
|
156
196
|
if (!this._event) {
|
|
157
|
-
this._event = (
|
|
197
|
+
this._event = (callback) => {
|
|
158
198
|
var _a;
|
|
159
199
|
if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.replay) && this._last !== undefined) {
|
|
160
|
-
|
|
200
|
+
callback(this._last);
|
|
161
201
|
}
|
|
202
|
+
const listener = new Listener(callback, Emitter.ENABLE_TRACKING ? Stacktrace.create() : undefined);
|
|
162
203
|
this._listeners.push(listener);
|
|
163
204
|
return {
|
|
164
205
|
dispose: () => {
|
|
@@ -166,28 +207,50 @@ class Emitter {
|
|
|
166
207
|
if (index > -1) {
|
|
167
208
|
this._listeners.splice(index, 1);
|
|
168
209
|
}
|
|
210
|
+
else if (Emitter.ENABLE_TRACKING) ;
|
|
169
211
|
},
|
|
170
212
|
};
|
|
171
213
|
};
|
|
214
|
+
if (Emitter.ENABLE_TRACKING) {
|
|
215
|
+
Emitter.MEMORY_LEAK_WATCHER.add(this._event, Stacktrace.create());
|
|
216
|
+
}
|
|
172
217
|
}
|
|
173
218
|
return this._event;
|
|
174
219
|
}
|
|
175
220
|
fire(e) {
|
|
176
221
|
this._last = e;
|
|
177
222
|
for (const listener of this._listeners) {
|
|
178
|
-
listener(e);
|
|
223
|
+
listener.callback(e);
|
|
179
224
|
}
|
|
180
225
|
}
|
|
181
226
|
dispose() {
|
|
182
|
-
this.
|
|
183
|
-
|
|
227
|
+
if (!this._disposed) {
|
|
228
|
+
this._disposed = true;
|
|
229
|
+
if (this._listeners.length > 0) {
|
|
230
|
+
if (Emitter.ENABLE_TRACKING) {
|
|
231
|
+
queueMicrotask(() => {
|
|
232
|
+
var _a;
|
|
233
|
+
// don't check until stack of execution is completed to allow for out-of-order disposals within the same execution block
|
|
234
|
+
for (const listener of this._listeners) {
|
|
235
|
+
console.warn((_a = listener.stacktrace) === null || _a === void 0 ? void 0 : _a.print());
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
this._listeners = [];
|
|
240
|
+
}
|
|
241
|
+
if (Emitter.ENABLE_TRACKING && this._event) {
|
|
242
|
+
Emitter.MEMORY_LEAK_WATCHER.delete(this._event);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
184
245
|
}
|
|
185
246
|
}
|
|
247
|
+
Emitter.ENABLE_TRACKING = false;
|
|
248
|
+
Emitter.MEMORY_LEAK_WATCHER = new LeakageMonitor();
|
|
186
249
|
function addDisposableWindowListener(element, type, listener, options) {
|
|
187
250
|
element.addEventListener(type, listener, options);
|
|
188
251
|
return {
|
|
189
252
|
dispose: () => {
|
|
190
|
-
element.removeEventListener(type, listener);
|
|
253
|
+
element.removeEventListener(type, listener, options);
|
|
191
254
|
},
|
|
192
255
|
};
|
|
193
256
|
}
|
|
@@ -195,7 +258,7 @@ function addDisposableListener(element, type, listener, options) {
|
|
|
195
258
|
element.addEventListener(type, listener, options);
|
|
196
259
|
return {
|
|
197
260
|
dispose: () => {
|
|
198
|
-
element.removeEventListener(type, listener);
|
|
261
|
+
element.removeEventListener(type, listener, options);
|
|
199
262
|
},
|
|
200
263
|
};
|
|
201
264
|
}
|
|
@@ -235,13 +298,13 @@ class CompositeDisposable {
|
|
|
235
298
|
}
|
|
236
299
|
constructor(...args) {
|
|
237
300
|
this._isDisposed = false;
|
|
238
|
-
this.
|
|
301
|
+
this._disposables = args;
|
|
239
302
|
}
|
|
240
303
|
addDisposables(...args) {
|
|
241
|
-
args.forEach((arg) => this.
|
|
304
|
+
args.forEach((arg) => this._disposables.push(arg));
|
|
242
305
|
}
|
|
243
306
|
dispose() {
|
|
244
|
-
this.
|
|
307
|
+
this._disposables.forEach((arg) => arg.dispose());
|
|
245
308
|
this._isDisposed = true;
|
|
246
309
|
}
|
|
247
310
|
}
|
|
@@ -331,6 +394,7 @@ class FocusTracker extends CompositeDisposable {
|
|
|
331
394
|
this.onDidFocus = this._onDidFocus.event;
|
|
332
395
|
this._onDidBlur = new Emitter();
|
|
333
396
|
this.onDidBlur = this._onDidBlur.event;
|
|
397
|
+
this.addDisposables(this._onDidFocus, this._onDidBlur);
|
|
334
398
|
let hasFocus = isAncestor(document.activeElement, element);
|
|
335
399
|
let loosingFocus = false;
|
|
336
400
|
const onFocus = () => {
|
|
@@ -375,11 +439,6 @@ class FocusTracker extends CompositeDisposable {
|
|
|
375
439
|
refreshState() {
|
|
376
440
|
this._refreshStateHandler();
|
|
377
441
|
}
|
|
378
|
-
dispose() {
|
|
379
|
-
super.dispose();
|
|
380
|
-
this._onDidBlur.dispose();
|
|
381
|
-
this._onDidFocus.dispose();
|
|
382
|
-
}
|
|
383
442
|
}
|
|
384
443
|
|
|
385
444
|
function createComponent(id, componentName, components = {}, frameworkComponents = {}, createFrameworkComponent, fallback) {
|
|
@@ -608,7 +667,7 @@ class Splitview {
|
|
|
608
667
|
this._orthogonalSize = value;
|
|
609
668
|
}
|
|
610
669
|
get length() {
|
|
611
|
-
return this.
|
|
670
|
+
return this.viewItems.length;
|
|
612
671
|
}
|
|
613
672
|
get proportions() {
|
|
614
673
|
return this._proportions ? [...this._proportions] : undefined;
|
|
@@ -627,12 +686,12 @@ class Splitview {
|
|
|
627
686
|
: 'vertical');
|
|
628
687
|
}
|
|
629
688
|
get minimumSize() {
|
|
630
|
-
return this.
|
|
689
|
+
return this.viewItems.reduce((r, item) => r + item.minimumSize, 0);
|
|
631
690
|
}
|
|
632
691
|
get maximumSize() {
|
|
633
692
|
return this.length === 0
|
|
634
693
|
? Number.POSITIVE_INFINITY
|
|
635
|
-
: this.
|
|
694
|
+
: this.viewItems.reduce((r, item) => r + item.maximumSize, 0);
|
|
636
695
|
}
|
|
637
696
|
get startSnappingEnabled() {
|
|
638
697
|
return this._startSnappingEnabled;
|
|
@@ -656,7 +715,7 @@ class Splitview {
|
|
|
656
715
|
}
|
|
657
716
|
constructor(container, options) {
|
|
658
717
|
this.container = container;
|
|
659
|
-
this.
|
|
718
|
+
this.viewItems = [];
|
|
660
719
|
this.sashes = [];
|
|
661
720
|
this._size = 0;
|
|
662
721
|
this._orthogonalSize = 0;
|
|
@@ -670,12 +729,12 @@ class Splitview {
|
|
|
670
729
|
this.onDidAddView = this._onDidAddView.event;
|
|
671
730
|
this._onDidRemoveView = new Emitter();
|
|
672
731
|
this.onDidRemoveView = this._onDidRemoveView.event;
|
|
673
|
-
this.resize = (index, delta, sizes = this.
|
|
674
|
-
if (index < 0 || index > this.
|
|
732
|
+
this.resize = (index, delta, sizes = this.viewItems.map((x) => x.size), lowPriorityIndexes, highPriorityIndexes, overloadMinDelta = Number.NEGATIVE_INFINITY, overloadMaxDelta = Number.POSITIVE_INFINITY, snapBefore, snapAfter) => {
|
|
733
|
+
if (index < 0 || index > this.viewItems.length) {
|
|
675
734
|
return 0;
|
|
676
735
|
}
|
|
677
736
|
const upIndexes = range(index, -1);
|
|
678
|
-
const downIndexes = range(index + 1, this.
|
|
737
|
+
const downIndexes = range(index + 1, this.viewItems.length);
|
|
679
738
|
//
|
|
680
739
|
if (highPriorityIndexes) {
|
|
681
740
|
for (const i of highPriorityIndexes) {
|
|
@@ -690,34 +749,34 @@ class Splitview {
|
|
|
690
749
|
}
|
|
691
750
|
}
|
|
692
751
|
//
|
|
693
|
-
const upItems = upIndexes.map((i) => this.
|
|
752
|
+
const upItems = upIndexes.map((i) => this.viewItems[i]);
|
|
694
753
|
const upSizes = upIndexes.map((i) => sizes[i]);
|
|
695
754
|
//
|
|
696
|
-
const downItems = downIndexes.map((i) => this.
|
|
755
|
+
const downItems = downIndexes.map((i) => this.viewItems[i]);
|
|
697
756
|
const downSizes = downIndexes.map((i) => sizes[i]);
|
|
698
757
|
//
|
|
699
|
-
const minDeltaUp = upIndexes.reduce((_, i) => _ + this.
|
|
700
|
-
const maxDeltaUp = upIndexes.reduce((_, i) => _ + this.
|
|
758
|
+
const minDeltaUp = upIndexes.reduce((_, i) => _ + this.viewItems[i].minimumSize - sizes[i], 0);
|
|
759
|
+
const maxDeltaUp = upIndexes.reduce((_, i) => _ + this.viewItems[i].maximumSize - sizes[i], 0);
|
|
701
760
|
//
|
|
702
761
|
const maxDeltaDown = downIndexes.length === 0
|
|
703
762
|
? Number.POSITIVE_INFINITY
|
|
704
|
-
: downIndexes.reduce((_, i) => _ + sizes[i] - this.
|
|
763
|
+
: downIndexes.reduce((_, i) => _ + sizes[i] - this.viewItems[i].minimumSize, 0);
|
|
705
764
|
const minDeltaDown = downIndexes.length === 0
|
|
706
765
|
? Number.NEGATIVE_INFINITY
|
|
707
|
-
: downIndexes.reduce((_, i) => _ + sizes[i] - this.
|
|
766
|
+
: downIndexes.reduce((_, i) => _ + sizes[i] - this.viewItems[i].maximumSize, 0);
|
|
708
767
|
//
|
|
709
768
|
const minDelta = Math.max(minDeltaUp, minDeltaDown);
|
|
710
769
|
const maxDelta = Math.min(maxDeltaDown, maxDeltaUp);
|
|
711
770
|
//
|
|
712
771
|
let snapped = false;
|
|
713
772
|
if (snapBefore) {
|
|
714
|
-
const snapView = this.
|
|
773
|
+
const snapView = this.viewItems[snapBefore.index];
|
|
715
774
|
const visible = delta >= snapBefore.limitDelta;
|
|
716
775
|
snapped = visible !== snapView.visible;
|
|
717
776
|
snapView.setVisible(visible, snapBefore.size);
|
|
718
777
|
}
|
|
719
778
|
if (!snapped && snapAfter) {
|
|
720
|
-
const snapView = this.
|
|
779
|
+
const snapView = this.viewItems[snapAfter.index];
|
|
721
780
|
const visible = delta < snapAfter.limitDelta;
|
|
722
781
|
snapped = visible !== snapView.visible;
|
|
723
782
|
snapView.setVisible(visible, snapAfter.size);
|
|
@@ -779,7 +838,7 @@ class Splitview {
|
|
|
779
838
|
);
|
|
780
839
|
});
|
|
781
840
|
// Initialize content size and proportions for first layout
|
|
782
|
-
this.contentSize = this.
|
|
841
|
+
this.contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
|
|
783
842
|
this.saveProportions();
|
|
784
843
|
}
|
|
785
844
|
}
|
|
@@ -796,18 +855,18 @@ class Splitview {
|
|
|
796
855
|
}
|
|
797
856
|
}
|
|
798
857
|
isViewVisible(index) {
|
|
799
|
-
if (index < 0 || index >= this.
|
|
858
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
800
859
|
throw new Error('Index out of bounds');
|
|
801
860
|
}
|
|
802
|
-
const viewItem = this.
|
|
861
|
+
const viewItem = this.viewItems[index];
|
|
803
862
|
return viewItem.visible;
|
|
804
863
|
}
|
|
805
864
|
setViewVisible(index, visible) {
|
|
806
|
-
if (index < 0 || index >= this.
|
|
865
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
807
866
|
throw new Error('Index out of bounds');
|
|
808
867
|
}
|
|
809
868
|
toggleClass(this.container, 'visible', visible);
|
|
810
|
-
const viewItem = this.
|
|
869
|
+
const viewItem = this.viewItems[index];
|
|
811
870
|
toggleClass(this.container, 'visible', visible);
|
|
812
871
|
viewItem.setVisible(visible, viewItem.size);
|
|
813
872
|
this.distributeEmptySpace(index);
|
|
@@ -815,33 +874,33 @@ class Splitview {
|
|
|
815
874
|
this.saveProportions();
|
|
816
875
|
}
|
|
817
876
|
getViewSize(index) {
|
|
818
|
-
if (index < 0 || index >= this.
|
|
877
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
819
878
|
return -1;
|
|
820
879
|
}
|
|
821
|
-
return this.
|
|
880
|
+
return this.viewItems[index].size;
|
|
822
881
|
}
|
|
823
882
|
resizeView(index, size) {
|
|
824
|
-
if (index < 0 || index >= this.
|
|
883
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
825
884
|
return;
|
|
826
885
|
}
|
|
827
|
-
const indexes = range(this.
|
|
886
|
+
const indexes = range(this.viewItems.length).filter((i) => i !== index);
|
|
828
887
|
const lowPriorityIndexes = [
|
|
829
|
-
...indexes.filter((i) => this.
|
|
888
|
+
...indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low),
|
|
830
889
|
index,
|
|
831
890
|
];
|
|
832
|
-
const highPriorityIndexes = indexes.filter((i) => this.
|
|
833
|
-
const item = this.
|
|
891
|
+
const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
|
|
892
|
+
const item = this.viewItems[index];
|
|
834
893
|
size = Math.round(size);
|
|
835
894
|
size = clamp(size, item.minimumSize, Math.min(item.maximumSize, this._size));
|
|
836
895
|
item.size = size;
|
|
837
896
|
this.relayout(lowPriorityIndexes, highPriorityIndexes);
|
|
838
897
|
}
|
|
839
898
|
getViews() {
|
|
840
|
-
return this.
|
|
899
|
+
return this.viewItems.map((x) => x.view);
|
|
841
900
|
}
|
|
842
901
|
onDidChange(item, size) {
|
|
843
|
-
const index = this.
|
|
844
|
-
if (index < 0 || index >= this.
|
|
902
|
+
const index = this.viewItems.indexOf(item);
|
|
903
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
845
904
|
return;
|
|
846
905
|
}
|
|
847
906
|
size = typeof size === 'number' ? size : item.size;
|
|
@@ -849,7 +908,7 @@ class Splitview {
|
|
|
849
908
|
item.size = size;
|
|
850
909
|
this.relayout([index]);
|
|
851
910
|
}
|
|
852
|
-
addView(view, size = { type: 'distribute' }, index = this.
|
|
911
|
+
addView(view, size = { type: 'distribute' }, index = this.viewItems.length, skipLayout) {
|
|
853
912
|
const container = document.createElement('div');
|
|
854
913
|
container.className = 'view';
|
|
855
914
|
container.appendChild(view.element);
|
|
@@ -867,24 +926,25 @@ class Splitview {
|
|
|
867
926
|
viewSize = view.minimumSize;
|
|
868
927
|
}
|
|
869
928
|
const disposable = view.onDidChange((newSize) => this.onDidChange(viewItem, newSize.size));
|
|
870
|
-
const
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
929
|
+
const viewItem = new ViewItem(container, view, viewSize, {
|
|
930
|
+
dispose: () => {
|
|
931
|
+
disposable.dispose();
|
|
932
|
+
this.viewContainer.removeChild(container);
|
|
933
|
+
},
|
|
934
|
+
});
|
|
935
|
+
if (index === this.viewItems.length) {
|
|
876
936
|
this.viewContainer.appendChild(container);
|
|
877
937
|
}
|
|
878
938
|
else {
|
|
879
939
|
this.viewContainer.insertBefore(container, this.viewContainer.children.item(index));
|
|
880
940
|
}
|
|
881
|
-
this.
|
|
882
|
-
if (this.
|
|
941
|
+
this.viewItems.splice(index, 0, viewItem);
|
|
942
|
+
if (this.viewItems.length > 1) {
|
|
883
943
|
//add sash
|
|
884
944
|
const sash = document.createElement('div');
|
|
885
945
|
sash.className = 'sash';
|
|
886
946
|
const onStart = (event) => {
|
|
887
|
-
for (const item of this.
|
|
947
|
+
for (const item of this.viewItems) {
|
|
888
948
|
item.enabled = false;
|
|
889
949
|
}
|
|
890
950
|
const iframes = [
|
|
@@ -899,27 +959,29 @@ class Splitview {
|
|
|
899
959
|
: event.clientY;
|
|
900
960
|
const sashIndex = firstIndex(this.sashes, (s) => s.container === sash);
|
|
901
961
|
//
|
|
902
|
-
const sizes = this.
|
|
962
|
+
const sizes = this.viewItems.map((x) => x.size);
|
|
903
963
|
//
|
|
904
964
|
let snapBefore;
|
|
905
965
|
let snapAfter;
|
|
906
966
|
const upIndexes = range(sashIndex, -1);
|
|
907
|
-
const downIndexes = range(sashIndex + 1, this.
|
|
908
|
-
const minDeltaUp = upIndexes.reduce((r, i) => r + (this.
|
|
909
|
-
const maxDeltaUp = upIndexes.reduce((r, i) => r + (this.
|
|
967
|
+
const downIndexes = range(sashIndex + 1, this.viewItems.length);
|
|
968
|
+
const minDeltaUp = upIndexes.reduce((r, i) => r + (this.viewItems[i].minimumSize - sizes[i]), 0);
|
|
969
|
+
const maxDeltaUp = upIndexes.reduce((r, i) => r + (this.viewItems[i].viewMaximumSize - sizes[i]), 0);
|
|
910
970
|
const maxDeltaDown = downIndexes.length === 0
|
|
911
971
|
? Number.POSITIVE_INFINITY
|
|
912
|
-
: downIndexes.reduce((r, i) => r +
|
|
972
|
+
: downIndexes.reduce((r, i) => r +
|
|
973
|
+
(sizes[i] - this.viewItems[i].minimumSize), 0);
|
|
913
974
|
const minDeltaDown = downIndexes.length === 0
|
|
914
975
|
? Number.NEGATIVE_INFINITY
|
|
915
976
|
: downIndexes.reduce((r, i) => r +
|
|
916
|
-
(sizes[i] -
|
|
977
|
+
(sizes[i] -
|
|
978
|
+
this.viewItems[i].viewMaximumSize), 0);
|
|
917
979
|
const minDelta = Math.max(minDeltaUp, minDeltaDown);
|
|
918
980
|
const maxDelta = Math.min(maxDeltaDown, maxDeltaUp);
|
|
919
981
|
const snapBeforeIndex = this.findFirstSnapIndex(upIndexes);
|
|
920
982
|
const snapAfterIndex = this.findFirstSnapIndex(downIndexes);
|
|
921
983
|
if (typeof snapBeforeIndex === 'number') {
|
|
922
|
-
const snappedViewItem = this.
|
|
984
|
+
const snappedViewItem = this.viewItems[snapBeforeIndex];
|
|
923
985
|
const halfSize = Math.floor(snappedViewItem.viewMinimumSize / 2);
|
|
924
986
|
snapBefore = {
|
|
925
987
|
index: snapBeforeIndex,
|
|
@@ -930,7 +992,7 @@ class Splitview {
|
|
|
930
992
|
};
|
|
931
993
|
}
|
|
932
994
|
if (typeof snapAfterIndex === 'number') {
|
|
933
|
-
const snappedViewItem = this.
|
|
995
|
+
const snappedViewItem = this.viewItems[snapAfterIndex];
|
|
934
996
|
const halfSize = Math.floor(snappedViewItem.viewMinimumSize / 2);
|
|
935
997
|
snapAfter = {
|
|
936
998
|
index: snapAfterIndex,
|
|
@@ -951,7 +1013,7 @@ class Splitview {
|
|
|
951
1013
|
this.layoutViews();
|
|
952
1014
|
};
|
|
953
1015
|
const end = () => {
|
|
954
|
-
for (const item of this.
|
|
1016
|
+
for (const item of this.viewItems) {
|
|
955
1017
|
item.enabled = true;
|
|
956
1018
|
}
|
|
957
1019
|
for (const iframe of iframes) {
|
|
@@ -960,12 +1022,10 @@ class Splitview {
|
|
|
960
1022
|
this.saveProportions();
|
|
961
1023
|
document.removeEventListener('mousemove', mousemove);
|
|
962
1024
|
document.removeEventListener('mouseup', end);
|
|
963
|
-
document.removeEventListener('mouseend', end);
|
|
964
1025
|
this._onDidSashEnd.fire(undefined);
|
|
965
1026
|
};
|
|
966
1027
|
document.addEventListener('mousemove', mousemove);
|
|
967
1028
|
document.addEventListener('mouseup', end);
|
|
968
|
-
document.addEventListener('mouseend', end);
|
|
969
1029
|
};
|
|
970
1030
|
sash.addEventListener('mousedown', onStart);
|
|
971
1031
|
const sashItem = {
|
|
@@ -991,7 +1051,7 @@ class Splitview {
|
|
|
991
1051
|
distributeViewSizes() {
|
|
992
1052
|
const flexibleViewItems = [];
|
|
993
1053
|
let flexibleSize = 0;
|
|
994
|
-
for (const item of this.
|
|
1054
|
+
for (const item of this.viewItems) {
|
|
995
1055
|
if (item.maximumSize - item.minimumSize > 0) {
|
|
996
1056
|
flexibleViewItems.push(item);
|
|
997
1057
|
flexibleSize += item.size;
|
|
@@ -1001,17 +1061,17 @@ class Splitview {
|
|
|
1001
1061
|
for (const item of flexibleViewItems) {
|
|
1002
1062
|
item.size = clamp(size, item.minimumSize, item.maximumSize);
|
|
1003
1063
|
}
|
|
1004
|
-
const indexes = range(this.
|
|
1005
|
-
const lowPriorityIndexes = indexes.filter((i) => this.
|
|
1006
|
-
const highPriorityIndexes = indexes.filter((i) => this.
|
|
1064
|
+
const indexes = range(this.viewItems.length);
|
|
1065
|
+
const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
|
|
1066
|
+
const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
|
|
1007
1067
|
this.relayout(lowPriorityIndexes, highPriorityIndexes);
|
|
1008
1068
|
}
|
|
1009
1069
|
removeView(index, sizing, skipLayout = false) {
|
|
1010
1070
|
// Remove view
|
|
1011
|
-
const viewItem = this.
|
|
1071
|
+
const viewItem = this.viewItems.splice(index, 1)[0];
|
|
1012
1072
|
viewItem.dispose();
|
|
1013
1073
|
// Remove sash
|
|
1014
|
-
if (this.
|
|
1074
|
+
if (this.viewItems.length >= 1) {
|
|
1015
1075
|
const sashIndex = Math.max(index - 1, 0);
|
|
1016
1076
|
const sashItem = this.sashes.splice(sashIndex, 1)[0];
|
|
1017
1077
|
sashItem.disposable();
|
|
@@ -1026,10 +1086,10 @@ class Splitview {
|
|
|
1026
1086
|
return viewItem.view;
|
|
1027
1087
|
}
|
|
1028
1088
|
getViewCachedVisibleSize(index) {
|
|
1029
|
-
if (index < 0 || index >= this.
|
|
1089
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
1030
1090
|
throw new Error('Index out of bounds');
|
|
1031
1091
|
}
|
|
1032
|
-
const viewItem = this.
|
|
1092
|
+
const viewItem = this.viewItems[index];
|
|
1033
1093
|
return viewItem.cachedVisibleSize;
|
|
1034
1094
|
}
|
|
1035
1095
|
moveView(from, to) {
|
|
@@ -1045,14 +1105,14 @@ class Splitview {
|
|
|
1045
1105
|
this.size = size;
|
|
1046
1106
|
this.orthogonalSize = orthogonalSize;
|
|
1047
1107
|
if (!this.proportions) {
|
|
1048
|
-
const indexes = range(this.
|
|
1049
|
-
const lowPriorityIndexes = indexes.filter((i) => this.
|
|
1050
|
-
const highPriorityIndexes = indexes.filter((i) => this.
|
|
1051
|
-
this.resize(this.
|
|
1108
|
+
const indexes = range(this.viewItems.length);
|
|
1109
|
+
const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
|
|
1110
|
+
const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
|
|
1111
|
+
this.resize(this.viewItems.length - 1, size - previousSize, undefined, lowPriorityIndexes, highPriorityIndexes);
|
|
1052
1112
|
}
|
|
1053
1113
|
else {
|
|
1054
|
-
for (let i = 0; i < this.
|
|
1055
|
-
const item = this.
|
|
1114
|
+
for (let i = 0; i < this.viewItems.length; i++) {
|
|
1115
|
+
const item = this.viewItems[i];
|
|
1056
1116
|
item.size = clamp(Math.round(this.proportions[i] * size), item.minimumSize, item.maximumSize);
|
|
1057
1117
|
}
|
|
1058
1118
|
}
|
|
@@ -1060,18 +1120,18 @@ class Splitview {
|
|
|
1060
1120
|
this.layoutViews();
|
|
1061
1121
|
}
|
|
1062
1122
|
relayout(lowPriorityIndexes, highPriorityIndexes) {
|
|
1063
|
-
const contentSize = this.
|
|
1064
|
-
this.resize(this.
|
|
1123
|
+
const contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
|
|
1124
|
+
this.resize(this.viewItems.length - 1, this._size - contentSize, undefined, lowPriorityIndexes, highPriorityIndexes);
|
|
1065
1125
|
this.distributeEmptySpace();
|
|
1066
1126
|
this.layoutViews();
|
|
1067
1127
|
this.saveProportions();
|
|
1068
1128
|
}
|
|
1069
1129
|
distributeEmptySpace(lowPriorityIndex) {
|
|
1070
|
-
const contentSize = this.
|
|
1130
|
+
const contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
|
|
1071
1131
|
let emptyDelta = this.size - contentSize;
|
|
1072
|
-
const indexes = range(this.
|
|
1073
|
-
const lowPriorityIndexes = indexes.filter((i) => this.
|
|
1074
|
-
const highPriorityIndexes = indexes.filter((i) => this.
|
|
1132
|
+
const indexes = range(this.viewItems.length - 1, -1);
|
|
1133
|
+
const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
|
|
1134
|
+
const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
|
|
1075
1135
|
for (const index of highPriorityIndexes) {
|
|
1076
1136
|
pushToStart(indexes, index);
|
|
1077
1137
|
}
|
|
@@ -1082,7 +1142,7 @@ class Splitview {
|
|
|
1082
1142
|
pushToEnd(indexes, lowPriorityIndex);
|
|
1083
1143
|
}
|
|
1084
1144
|
for (let i = 0; emptyDelta !== 0 && i < indexes.length; i++) {
|
|
1085
|
-
const item = this.
|
|
1145
|
+
const item = this.viewItems[indexes[i]];
|
|
1086
1146
|
const size = clamp(item.size + emptyDelta, item.minimumSize, item.maximumSize);
|
|
1087
1147
|
const viewDelta = size - item.size;
|
|
1088
1148
|
emptyDelta -= viewDelta;
|
|
@@ -1091,16 +1151,16 @@ class Splitview {
|
|
|
1091
1151
|
}
|
|
1092
1152
|
saveProportions() {
|
|
1093
1153
|
if (this.proportionalLayout && this.contentSize > 0) {
|
|
1094
|
-
this._proportions = this.
|
|
1154
|
+
this._proportions = this.viewItems.map((i) => i.size / this.contentSize);
|
|
1095
1155
|
}
|
|
1096
1156
|
}
|
|
1097
1157
|
layoutViews() {
|
|
1098
|
-
this.contentSize = this.
|
|
1158
|
+
this.contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
|
|
1099
1159
|
let sum = 0;
|
|
1100
1160
|
const x = [];
|
|
1101
1161
|
this.updateSashEnablement();
|
|
1102
|
-
for (let i = 0; i < this.
|
|
1103
|
-
sum += this.
|
|
1162
|
+
for (let i = 0; i < this.viewItems.length - 1; i++) {
|
|
1163
|
+
sum += this.viewItems[i].size;
|
|
1104
1164
|
x.push(sum);
|
|
1105
1165
|
const offset = Math.min(Math.max(0, sum - 2), this.size - 4);
|
|
1106
1166
|
if (this._orientation === exports.Orientation.HORIZONTAL) {
|
|
@@ -1112,7 +1172,7 @@ class Splitview {
|
|
|
1112
1172
|
this.sashes[i].container.style.top = `${offset}px`;
|
|
1113
1173
|
}
|
|
1114
1174
|
}
|
|
1115
|
-
this.
|
|
1175
|
+
this.viewItems.forEach((view, i) => {
|
|
1116
1176
|
if (this._orientation === exports.Orientation.HORIZONTAL) {
|
|
1117
1177
|
view.container.style.width = `${view.size}px`;
|
|
1118
1178
|
view.container.style.left = i == 0 ? '0px' : `${x[i - 1]}px`;
|
|
@@ -1131,7 +1191,7 @@ class Splitview {
|
|
|
1131
1191
|
findFirstSnapIndex(indexes) {
|
|
1132
1192
|
// visible views first
|
|
1133
1193
|
for (const index of indexes) {
|
|
1134
|
-
const viewItem = this.
|
|
1194
|
+
const viewItem = this.viewItems[index];
|
|
1135
1195
|
if (!viewItem.visible) {
|
|
1136
1196
|
continue;
|
|
1137
1197
|
}
|
|
@@ -1141,7 +1201,7 @@ class Splitview {
|
|
|
1141
1201
|
}
|
|
1142
1202
|
// then, hidden views
|
|
1143
1203
|
for (const index of indexes) {
|
|
1144
|
-
const viewItem = this.
|
|
1204
|
+
const viewItem = this.viewItems[index];
|
|
1145
1205
|
if (viewItem.visible &&
|
|
1146
1206
|
viewItem.maximumSize - viewItem.minimumSize > 0) {
|
|
1147
1207
|
return undefined;
|
|
@@ -1154,10 +1214,10 @@ class Splitview {
|
|
|
1154
1214
|
}
|
|
1155
1215
|
updateSashEnablement() {
|
|
1156
1216
|
let previous = false;
|
|
1157
|
-
const collapsesDown = this.
|
|
1217
|
+
const collapsesDown = this.viewItems.map((i) => (previous = i.size - i.minimumSize > 0 || previous));
|
|
1158
1218
|
previous = false;
|
|
1159
|
-
const expandsDown = this.
|
|
1160
|
-
const reverseViews = [...this.
|
|
1219
|
+
const expandsDown = this.viewItems.map((i) => (previous = i.maximumSize - i.size > 0 || previous));
|
|
1220
|
+
const reverseViews = [...this.viewItems].reverse();
|
|
1161
1221
|
previous = false;
|
|
1162
1222
|
const collapsesUp = reverseViews
|
|
1163
1223
|
.map((i) => (previous = i.size - i.minimumSize > 0 || previous))
|
|
@@ -1169,19 +1229,19 @@ class Splitview {
|
|
|
1169
1229
|
let position = 0;
|
|
1170
1230
|
for (let index = 0; index < this.sashes.length; index++) {
|
|
1171
1231
|
const sash = this.sashes[index];
|
|
1172
|
-
const viewItem = this.
|
|
1232
|
+
const viewItem = this.viewItems[index];
|
|
1173
1233
|
position += viewItem.size;
|
|
1174
1234
|
const min = !(collapsesDown[index] && expandsUp[index + 1]);
|
|
1175
1235
|
const max = !(expandsDown[index] && collapsesUp[index + 1]);
|
|
1176
1236
|
if (min && max) {
|
|
1177
1237
|
const upIndexes = range(index, -1);
|
|
1178
|
-
const downIndexes = range(index + 1, this.
|
|
1238
|
+
const downIndexes = range(index + 1, this.viewItems.length);
|
|
1179
1239
|
const snapBeforeIndex = this.findFirstSnapIndex(upIndexes);
|
|
1180
1240
|
const snapAfterIndex = this.findFirstSnapIndex(downIndexes);
|
|
1181
1241
|
const snappedBefore = typeof snapBeforeIndex === 'number' &&
|
|
1182
|
-
!this.
|
|
1242
|
+
!this.viewItems[snapBeforeIndex].visible;
|
|
1183
1243
|
const snappedAfter = typeof snapAfterIndex === 'number' &&
|
|
1184
|
-
!this.
|
|
1244
|
+
!this.viewItems[snapAfterIndex].visible;
|
|
1185
1245
|
if (snappedBefore &&
|
|
1186
1246
|
collapsesUp[index] &&
|
|
1187
1247
|
(position > 0 || this.startSnappingEnabled)) {
|
|
@@ -1241,6 +1301,9 @@ class Splitview {
|
|
|
1241
1301
|
break;
|
|
1242
1302
|
}
|
|
1243
1303
|
}
|
|
1304
|
+
for (const viewItem of this.viewItems) {
|
|
1305
|
+
viewItem.dispose();
|
|
1306
|
+
}
|
|
1244
1307
|
this.element.remove();
|
|
1245
1308
|
}
|
|
1246
1309
|
}
|
|
@@ -1675,7 +1738,7 @@ class BranchNode extends CompositeDisposable {
|
|
|
1675
1738
|
throw new Error('Invalid index');
|
|
1676
1739
|
}
|
|
1677
1740
|
this.splitview.removeView(index, sizing);
|
|
1678
|
-
this._removeChild(index);
|
|
1741
|
+
return this._removeChild(index);
|
|
1679
1742
|
}
|
|
1680
1743
|
_addChild(node, index) {
|
|
1681
1744
|
this.children.splice(index, 0, node);
|
|
@@ -1697,10 +1760,10 @@ class BranchNode extends CompositeDisposable {
|
|
|
1697
1760
|
});
|
|
1698
1761
|
}
|
|
1699
1762
|
dispose() {
|
|
1700
|
-
super.dispose();
|
|
1701
1763
|
this._childrenDisposable.dispose();
|
|
1702
|
-
this.children.forEach((child) => child.dispose());
|
|
1703
1764
|
this.splitview.dispose();
|
|
1765
|
+
this.children.forEach((child) => child.dispose());
|
|
1766
|
+
super.dispose();
|
|
1704
1767
|
}
|
|
1705
1768
|
}
|
|
1706
1769
|
|
|
@@ -1930,7 +1993,8 @@ class Gridview {
|
|
|
1930
1993
|
if (oldRoot.children.length === 1) {
|
|
1931
1994
|
// can remove one level of redundant branching if there is only a single child
|
|
1932
1995
|
const childReference = oldRoot.children[0];
|
|
1933
|
-
oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
|
|
1996
|
+
const child = oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
|
|
1997
|
+
child.dispose();
|
|
1934
1998
|
oldRoot.dispose();
|
|
1935
1999
|
this._root.addChild(
|
|
1936
2000
|
/**
|
|
@@ -2037,7 +2101,8 @@ class Gridview {
|
|
|
2037
2101
|
if (typeof newSiblingCachedVisibleSize === 'number') {
|
|
2038
2102
|
newSiblingSize = exports.Sizing.Invisible(newSiblingCachedVisibleSize);
|
|
2039
2103
|
}
|
|
2040
|
-
grandParent.removeChild(parentIndex);
|
|
2104
|
+
const child = grandParent.removeChild(parentIndex);
|
|
2105
|
+
child.dispose();
|
|
2041
2106
|
const newParent = new BranchNode(parent.orientation, this.proportionalLayout, this.styles, parent.size, parent.orthogonalSize);
|
|
2042
2107
|
grandParent.addChild(newParent, parent.size, parentIndex);
|
|
2043
2108
|
const newSibling = new LeafNode(parent.view, grandParent.orientation, parent.size);
|
|
@@ -2599,6 +2664,7 @@ class Droptarget extends CompositeDisposable {
|
|
|
2599
2664
|
}
|
|
2600
2665
|
dispose() {
|
|
2601
2666
|
this.removeDropTarget();
|
|
2667
|
+
super.dispose();
|
|
2602
2668
|
}
|
|
2603
2669
|
toggleClasses(quadrant, width, height) {
|
|
2604
2670
|
var _a, _b, _c, _d;
|
|
@@ -2776,8 +2842,8 @@ class ContentContainer extends CompositeDisposable {
|
|
|
2776
2842
|
if (this.panel.view) {
|
|
2777
2843
|
const _onDidFocus = this.panel.view.content.onDidFocus;
|
|
2778
2844
|
const _onDidBlur = this.panel.view.content.onDidBlur;
|
|
2779
|
-
const
|
|
2780
|
-
disposable.addDisposables(onDidFocus(() => this._onDidFocus.fire()), onDidBlur(() => this._onDidBlur.fire()));
|
|
2845
|
+
const focusTracker = trackFocus(this._element);
|
|
2846
|
+
disposable.addDisposables(focusTracker, focusTracker.onDidFocus(() => this._onDidFocus.fire()), focusTracker.onDidBlur(() => this._onDidBlur.fire()));
|
|
2781
2847
|
if (_onDidFocus) {
|
|
2782
2848
|
disposable.addDisposables(_onDidFocus(() => this._onDidFocus.fire()));
|
|
2783
2849
|
}
|
|
@@ -2816,24 +2882,32 @@ class DragHandler extends CompositeDisposable {
|
|
|
2816
2882
|
constructor(el) {
|
|
2817
2883
|
super();
|
|
2818
2884
|
this.el = el;
|
|
2819
|
-
this.
|
|
2885
|
+
this.dataDisposable = new MutableDisposable();
|
|
2886
|
+
this.pointerEventsDisposable = new MutableDisposable();
|
|
2820
2887
|
this._onDragStart = new Emitter();
|
|
2821
2888
|
this.onDragStart = this._onDragStart.event;
|
|
2822
|
-
this.
|
|
2889
|
+
this.addDisposables(this._onDragStart, this.dataDisposable, this.pointerEventsDisposable);
|
|
2823
2890
|
this.configure();
|
|
2824
2891
|
}
|
|
2825
2892
|
configure() {
|
|
2826
2893
|
this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
|
|
2827
|
-
|
|
2894
|
+
const iframes = [
|
|
2828
2895
|
...getElementsByTagName('iframe'),
|
|
2829
2896
|
...getElementsByTagName('webview'),
|
|
2830
2897
|
];
|
|
2831
|
-
|
|
2898
|
+
this.pointerEventsDisposable.value = {
|
|
2899
|
+
dispose: () => {
|
|
2900
|
+
for (const iframe of iframes) {
|
|
2901
|
+
iframe.style.pointerEvents = 'auto';
|
|
2902
|
+
}
|
|
2903
|
+
},
|
|
2904
|
+
};
|
|
2905
|
+
for (const iframe of iframes) {
|
|
2832
2906
|
iframe.style.pointerEvents = 'none';
|
|
2833
2907
|
}
|
|
2834
2908
|
this.el.classList.add('dv-dragged');
|
|
2835
2909
|
setTimeout(() => this.el.classList.remove('dv-dragged'), 0);
|
|
2836
|
-
this.
|
|
2910
|
+
this.dataDisposable.value = this.getData(event.dataTransfer);
|
|
2837
2911
|
if (event.dataTransfer) {
|
|
2838
2912
|
event.dataTransfer.effectAllowed = 'move';
|
|
2839
2913
|
/**
|
|
@@ -2848,11 +2922,8 @@ class DragHandler extends CompositeDisposable {
|
|
|
2848
2922
|
event.dataTransfer.setData('text/plain', '__dockview_internal_drag_event__');
|
|
2849
2923
|
}
|
|
2850
2924
|
}), addDisposableListener(this.el, 'dragend', () => {
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
}
|
|
2854
|
-
this.iframes = [];
|
|
2855
|
-
this.disposable.dispose();
|
|
2925
|
+
this.pointerEventsDisposable.dispose();
|
|
2926
|
+
this.dataDisposable.dispose();
|
|
2856
2927
|
}));
|
|
2857
2928
|
}
|
|
2858
2929
|
}
|
|
@@ -2870,13 +2941,12 @@ class Tab extends CompositeDisposable {
|
|
|
2870
2941
|
this.onChanged = this._onChanged.event;
|
|
2871
2942
|
this._onDropped = new Emitter();
|
|
2872
2943
|
this.onDrop = this._onDropped.event;
|
|
2873
|
-
this.addDisposables(this._onChanged, this._onDropped);
|
|
2874
2944
|
this._element = document.createElement('div');
|
|
2875
2945
|
this._element.className = 'tab';
|
|
2876
2946
|
this._element.tabIndex = 0;
|
|
2877
2947
|
this._element.draggable = true;
|
|
2878
2948
|
toggleClass(this.element, 'inactive-tab', true);
|
|
2879
|
-
this.addDisposables(new (class Handler extends DragHandler {
|
|
2949
|
+
this.addDisposables(this._onChanged, this._onDropped, new (class Handler extends DragHandler {
|
|
2880
2950
|
constructor() {
|
|
2881
2951
|
super(...arguments);
|
|
2882
2952
|
this.panelTransfer = LocalSelectionTransfer.getInstance();
|
|
@@ -2889,9 +2959,6 @@ class Tab extends CompositeDisposable {
|
|
|
2889
2959
|
},
|
|
2890
2960
|
};
|
|
2891
2961
|
}
|
|
2892
|
-
dispose() {
|
|
2893
|
-
//
|
|
2894
|
-
}
|
|
2895
2962
|
})(this._element));
|
|
2896
2963
|
this.addDisposables(addDisposableListener(this._element, 'mousedown', (event) => {
|
|
2897
2964
|
if (event.defaultPrevented) {
|
|
@@ -2926,7 +2993,7 @@ class Tab extends CompositeDisposable {
|
|
|
2926
2993
|
});
|
|
2927
2994
|
this.addDisposables(this.droptarget.onDrop((event) => {
|
|
2928
2995
|
this._onDropped.fire(event);
|
|
2929
|
-
}));
|
|
2996
|
+
}), this.droptarget);
|
|
2930
2997
|
}
|
|
2931
2998
|
setActive(isActive) {
|
|
2932
2999
|
toggleClass(this.element, 'active-tab', isActive);
|
|
@@ -2941,7 +3008,6 @@ class Tab extends CompositeDisposable {
|
|
|
2941
3008
|
}
|
|
2942
3009
|
dispose() {
|
|
2943
3010
|
super.dispose();
|
|
2944
|
-
this.droptarget.dispose();
|
|
2945
3011
|
}
|
|
2946
3012
|
}
|
|
2947
3013
|
|
|
@@ -2987,9 +3053,6 @@ class GroupDragHandler extends DragHandler {
|
|
|
2987
3053
|
},
|
|
2988
3054
|
};
|
|
2989
3055
|
}
|
|
2990
|
-
dispose() {
|
|
2991
|
-
//
|
|
2992
|
-
}
|
|
2993
3056
|
}
|
|
2994
3057
|
|
|
2995
3058
|
class VoidContainer extends CompositeDisposable {
|
|
@@ -3145,6 +3208,7 @@ class TabsContainer extends CompositeDisposable {
|
|
|
3145
3208
|
const tabToRemove = this.tabs.splice(index, 1)[0];
|
|
3146
3209
|
const { value, disposable } = tabToRemove;
|
|
3147
3210
|
disposable.dispose();
|
|
3211
|
+
value.dispose();
|
|
3148
3212
|
value.element.remove();
|
|
3149
3213
|
}
|
|
3150
3214
|
setActivePanel(panel) {
|
|
@@ -3188,9 +3252,10 @@ class TabsContainer extends CompositeDisposable {
|
|
|
3188
3252
|
}
|
|
3189
3253
|
dispose() {
|
|
3190
3254
|
super.dispose();
|
|
3191
|
-
this.tabs
|
|
3192
|
-
|
|
3193
|
-
|
|
3255
|
+
for (const { value, disposable } of this.tabs) {
|
|
3256
|
+
disposable.dispose();
|
|
3257
|
+
value.dispose();
|
|
3258
|
+
}
|
|
3194
3259
|
this.tabs = [];
|
|
3195
3260
|
}
|
|
3196
3261
|
}
|
|
@@ -3288,7 +3353,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
|
|
|
3288
3353
|
container.append(this.tabsContainer.element, this.contentContainer.element);
|
|
3289
3354
|
this.header.hidden = !!options.hideHeader;
|
|
3290
3355
|
this.locked = !!options.locked;
|
|
3291
|
-
this.addDisposables(this.
|
|
3356
|
+
this.addDisposables(this.tabsContainer.onDrop((event) => {
|
|
3292
3357
|
this.handleDropEvent(event.event, 'center', event.index);
|
|
3293
3358
|
}), this.contentContainer.onDidFocus(() => {
|
|
3294
3359
|
this.accessor.doSetGroupActive(this.groupPanel, true);
|
|
@@ -3296,7 +3361,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
|
|
|
3296
3361
|
// noop
|
|
3297
3362
|
}), this.dropTarget.onDrop((event) => {
|
|
3298
3363
|
this.handleDropEvent(event.nativeEvent, event.position);
|
|
3299
|
-
}));
|
|
3364
|
+
}), this._onMove, this._onDidChange, this._onDidDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange);
|
|
3300
3365
|
}
|
|
3301
3366
|
initialize() {
|
|
3302
3367
|
var _a, _b;
|
|
@@ -3730,8 +3795,7 @@ class BaseGrid extends Resizable {
|
|
|
3730
3795
|
this.layout(0, 0, true); // set some elements height/widths
|
|
3731
3796
|
this.addDisposables(this.gridview.onDidChange(() => {
|
|
3732
3797
|
this._bufferOnDidLayoutChange.fire();
|
|
3733
|
-
}))
|
|
3734
|
-
this.addDisposables(exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
|
|
3798
|
+
}), exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
|
|
3735
3799
|
this._bufferOnDidLayoutChange.fire();
|
|
3736
3800
|
}), this._bufferOnDidLayoutChange.onEvent(() => {
|
|
3737
3801
|
this._onDidLayoutChange.fire();
|
|
@@ -3834,7 +3898,6 @@ class BaseGrid extends Resizable {
|
|
|
3834
3898
|
this.gridview.layout(width, height);
|
|
3835
3899
|
}
|
|
3836
3900
|
dispose() {
|
|
3837
|
-
super.dispose();
|
|
3838
3901
|
this._onDidActiveGroupChange.dispose();
|
|
3839
3902
|
this._onDidAddGroup.dispose();
|
|
3840
3903
|
this._onDidRemoveGroup.dispose();
|
|
@@ -3843,6 +3906,7 @@ class BaseGrid extends Resizable {
|
|
|
3843
3906
|
group.dispose();
|
|
3844
3907
|
}
|
|
3845
3908
|
this.gridview.dispose();
|
|
3909
|
+
super.dispose();
|
|
3846
3910
|
}
|
|
3847
3911
|
}
|
|
3848
3912
|
|
|
@@ -3906,7 +3970,7 @@ class PanelApiImpl extends CompositeDisposable {
|
|
|
3906
3970
|
//
|
|
3907
3971
|
this._onUpdateParameters = new Emitter();
|
|
3908
3972
|
this.onUpdateParameters = this._onUpdateParameters.event;
|
|
3909
|
-
this.addDisposables(this.
|
|
3973
|
+
this.addDisposables(this.onDidFocusChange((event) => {
|
|
3910
3974
|
this._isFocused = event.isFocused;
|
|
3911
3975
|
}), this.onDidActiveChange((event) => {
|
|
3912
3976
|
this._isActive = event.isActive;
|
|
@@ -3915,14 +3979,12 @@ class PanelApiImpl extends CompositeDisposable {
|
|
|
3915
3979
|
}), this.onDidDimensionsChange((event) => {
|
|
3916
3980
|
this._width = event.width;
|
|
3917
3981
|
this._height = event.height;
|
|
3918
|
-
}));
|
|
3982
|
+
}), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onFocusEvent, this._onActiveChange, this._onVisibilityChange, this._onUpdateParameters);
|
|
3919
3983
|
}
|
|
3920
3984
|
initialize(panel) {
|
|
3921
3985
|
this.panelUpdatesDisposable.value = this._onUpdateParameters.event((parameters) => {
|
|
3922
3986
|
panel.update({
|
|
3923
|
-
params:
|
|
3924
|
-
params: parameters,
|
|
3925
|
-
},
|
|
3987
|
+
params: parameters,
|
|
3926
3988
|
});
|
|
3927
3989
|
});
|
|
3928
3990
|
}
|
|
@@ -4017,12 +4079,12 @@ class BasePanelView extends CompositeDisposable {
|
|
|
4017
4079
|
this._element.style.height = '100%';
|
|
4018
4080
|
this._element.style.width = '100%';
|
|
4019
4081
|
this._element.style.overflow = 'hidden';
|
|
4020
|
-
const
|
|
4021
|
-
this.addDisposables(this.api, onDidFocus(() => {
|
|
4082
|
+
const focusTracker = trackFocus(this._element);
|
|
4083
|
+
this.addDisposables(this.api, focusTracker.onDidFocus(() => {
|
|
4022
4084
|
this.api._onDidChangeFocus.fire({ isFocused: true });
|
|
4023
|
-
}), onDidBlur(() => {
|
|
4085
|
+
}), focusTracker.onDidBlur(() => {
|
|
4024
4086
|
this.api._onDidChangeFocus.fire({ isFocused: false });
|
|
4025
|
-
}));
|
|
4087
|
+
}), focusTracker);
|
|
4026
4088
|
}
|
|
4027
4089
|
focus() {
|
|
4028
4090
|
this.api._onFocusEvent.fire();
|
|
@@ -4043,7 +4105,18 @@ class BasePanelView extends CompositeDisposable {
|
|
|
4043
4105
|
}
|
|
4044
4106
|
update(event) {
|
|
4045
4107
|
var _a, _b;
|
|
4108
|
+
// merge the new parameters with the existing parameters
|
|
4046
4109
|
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) });
|
|
4110
|
+
/**
|
|
4111
|
+
* delete new keys that have a value of undefined,
|
|
4112
|
+
* allow values of null
|
|
4113
|
+
*/
|
|
4114
|
+
for (const key of Object.keys(event.params)) {
|
|
4115
|
+
if (event.params[key] === undefined) {
|
|
4116
|
+
delete this._params.params[key];
|
|
4117
|
+
}
|
|
4118
|
+
}
|
|
4119
|
+
// update the view with the updated props
|
|
4047
4120
|
(_b = this.part) === null || _b === void 0 ? void 0 : _b.update({ params: this._params.params });
|
|
4048
4121
|
}
|
|
4049
4122
|
toJSON() {
|
|
@@ -4057,9 +4130,9 @@ class BasePanelView extends CompositeDisposable {
|
|
|
4057
4130
|
}
|
|
4058
4131
|
dispose() {
|
|
4059
4132
|
var _a;
|
|
4060
|
-
super.dispose();
|
|
4061
4133
|
this.api.dispose();
|
|
4062
4134
|
(_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
4135
|
+
super.dispose();
|
|
4063
4136
|
}
|
|
4064
4137
|
}
|
|
4065
4138
|
|
|
@@ -4438,7 +4511,7 @@ class GridviewPanel extends BasePanelView {
|
|
|
4438
4511
|
this._maximumHeight = options.maximumHeight;
|
|
4439
4512
|
}
|
|
4440
4513
|
this.api.initialize(this); // TODO: required to by-pass 'super before this' requirement
|
|
4441
|
-
this.addDisposables(this.
|
|
4514
|
+
this.addDisposables(this.api.onVisibilityChange((event) => {
|
|
4442
4515
|
const { isVisible } = event;
|
|
4443
4516
|
const { accessor } = this._params;
|
|
4444
4517
|
accessor.setVisible(this, isVisible);
|
|
@@ -4467,7 +4540,7 @@ class GridviewPanel extends BasePanelView {
|
|
|
4467
4540
|
height: event.height,
|
|
4468
4541
|
width: event.width,
|
|
4469
4542
|
});
|
|
4470
|
-
}));
|
|
4543
|
+
}), this._onDidChange);
|
|
4471
4544
|
}
|
|
4472
4545
|
setVisible(isVisible) {
|
|
4473
4546
|
this.api._onDidVisibilityChange.fire({ isVisible });
|
|
@@ -4624,7 +4697,7 @@ class DockviewPanelApiImpl extends GridviewPanelApiImpl {
|
|
|
4624
4697
|
this.addDisposables(this.disposable, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange);
|
|
4625
4698
|
}
|
|
4626
4699
|
setTitle(title) {
|
|
4627
|
-
this.panel.
|
|
4700
|
+
this.panel.setTitle(title);
|
|
4628
4701
|
}
|
|
4629
4702
|
close() {
|
|
4630
4703
|
this.group.model.closePanel(this.panel);
|
|
@@ -4689,12 +4762,18 @@ class DockviewPanel extends CompositeDisposable {
|
|
|
4689
4762
|
}
|
|
4690
4763
|
}
|
|
4691
4764
|
update(event) {
|
|
4692
|
-
|
|
4693
|
-
this._params = Object.assign(Object.assign({}, (this._params || {})), event.params
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4765
|
+
// merge the new parameters with the existing parameters
|
|
4766
|
+
this._params = Object.assign(Object.assign({}, (this._params || {})), event.params);
|
|
4767
|
+
/**
|
|
4768
|
+
* delete new keys that have a value of undefined,
|
|
4769
|
+
* allow values of null
|
|
4770
|
+
*/
|
|
4771
|
+
for (const key of Object.keys(event.params)) {
|
|
4772
|
+
if (event.params[key] === undefined) {
|
|
4773
|
+
delete this._params[key];
|
|
4774
|
+
}
|
|
4697
4775
|
}
|
|
4776
|
+
// update the view with the updated props
|
|
4698
4777
|
this.view.update({
|
|
4699
4778
|
params: {
|
|
4700
4779
|
params: this._params,
|
|
@@ -5070,7 +5149,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
5070
5149
|
size: { type: 'pixels', value: 20 },
|
|
5071
5150
|
},
|
|
5072
5151
|
});
|
|
5073
|
-
this.addDisposables(dropTarget
|
|
5152
|
+
this.addDisposables(dropTarget.onDrop((event) => {
|
|
5074
5153
|
const data = getPanelData();
|
|
5075
5154
|
if (data) {
|
|
5076
5155
|
this.moveGroupOrPanel(this.orthogonalize(event.position), data.groupId, data.panelId || undefined, 'center');
|
|
@@ -5078,7 +5157,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
5078
5157
|
else {
|
|
5079
5158
|
this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api, group: null, getData: getPanelData }));
|
|
5080
5159
|
}
|
|
5081
|
-
}));
|
|
5160
|
+
}), dropTarget);
|
|
5082
5161
|
this._api = new DockviewApi(this);
|
|
5083
5162
|
this.updateWatermark();
|
|
5084
5163
|
}
|
|
@@ -5402,31 +5481,33 @@ class DockviewComponent extends BaseGrid {
|
|
|
5402
5481
|
}
|
|
5403
5482
|
super.doRemoveGroup(group, { skipActive });
|
|
5404
5483
|
}
|
|
5405
|
-
moveGroupOrPanel(
|
|
5484
|
+
moveGroupOrPanel(destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
|
|
5406
5485
|
var _a;
|
|
5407
|
-
const sourceGroup =
|
|
5408
|
-
? (_a = this._groups.get(
|
|
5486
|
+
const sourceGroup = sourceGroupId
|
|
5487
|
+
? (_a = this._groups.get(sourceGroupId)) === null || _a === void 0 ? void 0 : _a.value
|
|
5409
5488
|
: undefined;
|
|
5410
|
-
if (
|
|
5489
|
+
if (sourceItemId === undefined) {
|
|
5411
5490
|
if (sourceGroup) {
|
|
5412
|
-
this.moveGroup(sourceGroup,
|
|
5491
|
+
this.moveGroup(sourceGroup, destinationGroup, destinationTarget);
|
|
5413
5492
|
}
|
|
5414
5493
|
return;
|
|
5415
5494
|
}
|
|
5416
|
-
if (!
|
|
5417
|
-
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(
|
|
5418
|
-
this.panels.find((panel) => panel.id ===
|
|
5495
|
+
if (!destinationTarget || destinationTarget === 'center') {
|
|
5496
|
+
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
|
|
5497
|
+
this.panels.find((panel) => panel.id === sourceItemId);
|
|
5419
5498
|
if (!groupItem) {
|
|
5420
|
-
throw new Error(`No panel with id ${
|
|
5499
|
+
throw new Error(`No panel with id ${sourceItemId}`);
|
|
5421
5500
|
}
|
|
5422
5501
|
if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
|
|
5423
5502
|
this.doRemoveGroup(sourceGroup);
|
|
5424
5503
|
}
|
|
5425
|
-
|
|
5504
|
+
destinationGroup.model.openPanel(groupItem, {
|
|
5505
|
+
index: destinationIndex,
|
|
5506
|
+
});
|
|
5426
5507
|
}
|
|
5427
5508
|
else {
|
|
5428
|
-
const referenceLocation = getGridLocation(
|
|
5429
|
-
const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation,
|
|
5509
|
+
const referenceLocation = getGridLocation(destinationGroup.element);
|
|
5510
|
+
const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
|
|
5430
5511
|
if (sourceGroup && sourceGroup.size < 2) {
|
|
5431
5512
|
const [targetParentLocation, to] = tail(targetLocation);
|
|
5432
5513
|
const sourceLocation = getGridLocation(sourceGroup.element);
|
|
@@ -5444,18 +5525,18 @@ class DockviewComponent extends BaseGrid {
|
|
|
5444
5525
|
skipDispose: true,
|
|
5445
5526
|
});
|
|
5446
5527
|
// after deleting the group we need to re-evaulate the ref location
|
|
5447
|
-
const updatedReferenceLocation = getGridLocation(
|
|
5448
|
-
const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation,
|
|
5528
|
+
const updatedReferenceLocation = getGridLocation(destinationGroup.element);
|
|
5529
|
+
const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
|
|
5449
5530
|
this.doAddGroup(targetGroup, location);
|
|
5450
5531
|
}
|
|
5451
5532
|
}
|
|
5452
5533
|
else {
|
|
5453
|
-
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(
|
|
5454
|
-
this.panels.find((panel) => panel.id ===
|
|
5534
|
+
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
|
|
5535
|
+
this.panels.find((panel) => panel.id === sourceItemId);
|
|
5455
5536
|
if (!groupItem) {
|
|
5456
|
-
throw new Error(`No panel with id ${
|
|
5537
|
+
throw new Error(`No panel with id ${sourceItemId}`);
|
|
5457
5538
|
}
|
|
5458
|
-
const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation,
|
|
5539
|
+
const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
|
|
5459
5540
|
const group = this.createGroupAtLocation(dropLocation);
|
|
5460
5541
|
group.model.openPanel(groupItem);
|
|
5461
5542
|
}
|
|
@@ -5549,11 +5630,11 @@ class DockviewComponent extends BaseGrid {
|
|
|
5549
5630
|
return (_a = Array.from(this._groups.values()).find((group) => group.value.model.containsPanel(panel))) === null || _a === void 0 ? void 0 : _a.value;
|
|
5550
5631
|
}
|
|
5551
5632
|
dispose() {
|
|
5552
|
-
super.dispose();
|
|
5553
5633
|
this._onDidActivePanelChange.dispose();
|
|
5554
5634
|
this._onDidAddPanel.dispose();
|
|
5555
5635
|
this._onDidRemovePanel.dispose();
|
|
5556
5636
|
this._onDidLayoutFromJSON.dispose();
|
|
5637
|
+
super.dispose();
|
|
5557
5638
|
}
|
|
5558
5639
|
}
|
|
5559
5640
|
|
|
@@ -5811,7 +5892,7 @@ class SplitviewComponent extends Resizable {
|
|
|
5811
5892
|
}
|
|
5812
5893
|
set splitview(value) {
|
|
5813
5894
|
this._splitview = value;
|
|
5814
|
-
this.
|
|
5895
|
+
this._splitviewChangeDisposable.value = new CompositeDisposable(this._splitview.onDidSashEnd(() => {
|
|
5815
5896
|
this._onDidLayoutChange.fire(undefined);
|
|
5816
5897
|
}), this._splitview.onDidAddView((e) => this._onDidAddView.fire(e)), this._splitview.onDidRemoveView((e) => this._onDidRemoveView.fire(e)));
|
|
5817
5898
|
}
|
|
@@ -5833,7 +5914,7 @@ class SplitviewComponent extends Resizable {
|
|
|
5833
5914
|
}
|
|
5834
5915
|
constructor(options) {
|
|
5835
5916
|
super(options.parentElement);
|
|
5836
|
-
this.
|
|
5917
|
+
this._splitviewChangeDisposable = new MutableDisposable();
|
|
5837
5918
|
this._panels = new Map();
|
|
5838
5919
|
this._onDidLayoutfromJSON = new Emitter();
|
|
5839
5920
|
this.onDidLayoutFromJSON = this._onDidLayoutfromJSON.event;
|
|
@@ -5851,7 +5932,7 @@ class SplitviewComponent extends Resizable {
|
|
|
5851
5932
|
options.frameworkComponents = {};
|
|
5852
5933
|
}
|
|
5853
5934
|
this.splitview = new Splitview(this.element, options);
|
|
5854
|
-
this.addDisposables(this.
|
|
5935
|
+
this.addDisposables(this._onDidAddView, this._onDidLayoutfromJSON, this._onDidRemoveView, this._onDidLayoutChange);
|
|
5855
5936
|
}
|
|
5856
5937
|
updateOptions(options) {
|
|
5857
5938
|
const hasOrientationChanged = typeof options.orientation === 'string' &&
|
|
@@ -5889,15 +5970,15 @@ class SplitviewComponent extends Resizable {
|
|
|
5889
5970
|
}
|
|
5890
5971
|
}
|
|
5891
5972
|
removePanel(panel, sizing) {
|
|
5892
|
-
const
|
|
5893
|
-
if (!
|
|
5973
|
+
const item = this._panels.get(panel.id);
|
|
5974
|
+
if (!item) {
|
|
5894
5975
|
throw new Error(`unknown splitview panel ${panel.id}`);
|
|
5895
5976
|
}
|
|
5896
|
-
|
|
5897
|
-
disposable.value.dispose();
|
|
5977
|
+
item.dispose();
|
|
5898
5978
|
this._panels.delete(panel.id);
|
|
5899
5979
|
const index = this.panels.findIndex((_) => _ === panel);
|
|
5900
|
-
this.splitview.removeView(index, sizing);
|
|
5980
|
+
const removedView = this.splitview.removeView(index, sizing);
|
|
5981
|
+
removedView.dispose();
|
|
5901
5982
|
const panels = this.panels;
|
|
5902
5983
|
if (panels.length > 0) {
|
|
5903
5984
|
this.setActive(panels[panels.length - 1]);
|
|
@@ -5944,7 +6025,7 @@ class SplitviewComponent extends Resizable {
|
|
|
5944
6025
|
}
|
|
5945
6026
|
this.setActive(view, true);
|
|
5946
6027
|
});
|
|
5947
|
-
this._panels.set(view.id,
|
|
6028
|
+
this._panels.set(view.id, disposable);
|
|
5948
6029
|
}
|
|
5949
6030
|
toJSON() {
|
|
5950
6031
|
var _a;
|
|
@@ -6017,20 +6098,26 @@ class SplitviewComponent extends Resizable {
|
|
|
6017
6098
|
this._onDidLayoutfromJSON.fire();
|
|
6018
6099
|
}
|
|
6019
6100
|
clear() {
|
|
6020
|
-
for (const
|
|
6021
|
-
|
|
6022
|
-
value.value.dispose();
|
|
6101
|
+
for (const disposable of this._panels.values()) {
|
|
6102
|
+
disposable.dispose();
|
|
6023
6103
|
}
|
|
6024
6104
|
this._panels.clear();
|
|
6025
|
-
this.splitview.
|
|
6105
|
+
while (this.splitview.length > 0) {
|
|
6106
|
+
const view = this.splitview.removeView(0, exports.Sizing.Distribute, true);
|
|
6107
|
+
view.dispose();
|
|
6108
|
+
}
|
|
6026
6109
|
}
|
|
6027
6110
|
dispose() {
|
|
6028
|
-
for (const
|
|
6029
|
-
|
|
6030
|
-
value.value.dispose();
|
|
6111
|
+
for (const disposable of this._panels.values()) {
|
|
6112
|
+
disposable.dispose();
|
|
6031
6113
|
}
|
|
6032
6114
|
this._panels.clear();
|
|
6115
|
+
const views = this.splitview.getViews();
|
|
6116
|
+
this._splitviewChangeDisposable.dispose();
|
|
6033
6117
|
this.splitview.dispose();
|
|
6118
|
+
for (const view of views) {
|
|
6119
|
+
view.dispose();
|
|
6120
|
+
}
|
|
6034
6121
|
super.dispose();
|
|
6035
6122
|
}
|
|
6036
6123
|
}
|