dockview 1.7.2 → 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.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview
3
- * @version 1.7.2
3
+ * @version 1.7.4
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
- // dumb event emitter with better typings than nodes event emitter
148
- // https://github.com/microsoft/vscode/blob/master/src/vs/base/common/event.ts
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 = (listener) => {
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
- listener(this._last);
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,23 +207,45 @@ 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._listeners = [];
183
- this._disposed = true;
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 {
@@ -235,13 +298,13 @@ class CompositeDisposable {
235
298
  }
236
299
  constructor(...args) {
237
300
  this._isDisposed = false;
238
- this.disposables = args;
301
+ this._disposables = args;
239
302
  }
240
303
  addDisposables(...args) {
241
- args.forEach((arg) => this.disposables.push(arg));
304
+ args.forEach((arg) => this._disposables.push(arg));
242
305
  }
243
306
  dispose() {
244
- this.disposables.forEach((arg) => arg.dispose());
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.views.length;
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.views.reduce((r, item) => r + item.minimumSize, 0);
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.views.reduce((r, item) => r + item.maximumSize, 0);
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.views = [];
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.views.map((x) => x.size), lowPriorityIndexes, highPriorityIndexes, overloadMinDelta = Number.NEGATIVE_INFINITY, overloadMaxDelta = Number.POSITIVE_INFINITY, snapBefore, snapAfter) => {
674
- if (index < 0 || index > this.views.length) {
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.views.length);
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.views[i]);
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.views[i]);
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.views[i].minimumSize - sizes[i], 0);
700
- const maxDeltaUp = upIndexes.reduce((_, i) => _ + this.views[i].maximumSize - sizes[i], 0);
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.views[i].minimumSize, 0);
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.views[i].maximumSize, 0);
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.views[snapBefore.index];
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.views[snapAfter.index];
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.views.reduce((r, i) => r + i.size, 0);
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.views.length) {
858
+ if (index < 0 || index >= this.viewItems.length) {
800
859
  throw new Error('Index out of bounds');
801
860
  }
802
- const viewItem = this.views[index];
861
+ const viewItem = this.viewItems[index];
803
862
  return viewItem.visible;
804
863
  }
805
864
  setViewVisible(index, visible) {
806
- if (index < 0 || index >= this.views.length) {
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.views[index];
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.views.length) {
877
+ if (index < 0 || index >= this.viewItems.length) {
819
878
  return -1;
820
879
  }
821
- return this.views[index].size;
880
+ return this.viewItems[index].size;
822
881
  }
823
882
  resizeView(index, size) {
824
- if (index < 0 || index >= this.views.length) {
883
+ if (index < 0 || index >= this.viewItems.length) {
825
884
  return;
826
885
  }
827
- const indexes = range(this.views.length).filter((i) => i !== index);
886
+ const indexes = range(this.viewItems.length).filter((i) => i !== index);
828
887
  const lowPriorityIndexes = [
829
- ...indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.Low),
888
+ ...indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low),
830
889
  index,
831
890
  ];
832
- const highPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.High);
833
- const item = this.views[index];
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.views.map((x) => x.view);
899
+ return this.viewItems.map((x) => x.view);
841
900
  }
842
901
  onDidChange(item, size) {
843
- const index = this.views.indexOf(item);
844
- if (index < 0 || index >= this.views.length) {
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.views.length, skipLayout) {
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 dispose = () => {
871
- disposable === null || disposable === void 0 ? void 0 : disposable.dispose();
872
- this.viewContainer.removeChild(container);
873
- };
874
- const viewItem = new ViewItem(container, view, viewSize, { dispose });
875
- if (index === this.views.length) {
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.views.splice(index, 0, viewItem);
882
- if (this.views.length > 1) {
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.views) {
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.views.map((x) => x.size);
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.views.length);
908
- const minDeltaUp = upIndexes.reduce((r, i) => r + (this.views[i].minimumSize - sizes[i]), 0);
909
- const maxDeltaUp = upIndexes.reduce((r, i) => r + (this.views[i].viewMaximumSize - sizes[i]), 0);
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 + (sizes[i] - this.views[i].minimumSize), 0);
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] - this.views[i].viewMaximumSize), 0);
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.views[snapBeforeIndex];
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.views[snapAfterIndex];
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.views) {
1016
+ for (const item of this.viewItems) {
955
1017
  item.enabled = true;
956
1018
  }
957
1019
  for (const iframe of iframes) {
@@ -991,7 +1053,7 @@ class Splitview {
991
1053
  distributeViewSizes() {
992
1054
  const flexibleViewItems = [];
993
1055
  let flexibleSize = 0;
994
- for (const item of this.views) {
1056
+ for (const item of this.viewItems) {
995
1057
  if (item.maximumSize - item.minimumSize > 0) {
996
1058
  flexibleViewItems.push(item);
997
1059
  flexibleSize += item.size;
@@ -1001,17 +1063,17 @@ class Splitview {
1001
1063
  for (const item of flexibleViewItems) {
1002
1064
  item.size = clamp(size, item.minimumSize, item.maximumSize);
1003
1065
  }
1004
- const indexes = range(this.views.length);
1005
- const lowPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.Low);
1006
- const highPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.High);
1066
+ const indexes = range(this.viewItems.length);
1067
+ const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
1068
+ const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
1007
1069
  this.relayout(lowPriorityIndexes, highPriorityIndexes);
1008
1070
  }
1009
1071
  removeView(index, sizing, skipLayout = false) {
1010
1072
  // Remove view
1011
- const viewItem = this.views.splice(index, 1)[0];
1073
+ const viewItem = this.viewItems.splice(index, 1)[0];
1012
1074
  viewItem.dispose();
1013
1075
  // Remove sash
1014
- if (this.views.length >= 1) {
1076
+ if (this.viewItems.length >= 1) {
1015
1077
  const sashIndex = Math.max(index - 1, 0);
1016
1078
  const sashItem = this.sashes.splice(sashIndex, 1)[0];
1017
1079
  sashItem.disposable();
@@ -1026,10 +1088,10 @@ class Splitview {
1026
1088
  return viewItem.view;
1027
1089
  }
1028
1090
  getViewCachedVisibleSize(index) {
1029
- if (index < 0 || index >= this.views.length) {
1091
+ if (index < 0 || index >= this.viewItems.length) {
1030
1092
  throw new Error('Index out of bounds');
1031
1093
  }
1032
- const viewItem = this.views[index];
1094
+ const viewItem = this.viewItems[index];
1033
1095
  return viewItem.cachedVisibleSize;
1034
1096
  }
1035
1097
  moveView(from, to) {
@@ -1045,14 +1107,14 @@ class Splitview {
1045
1107
  this.size = size;
1046
1108
  this.orthogonalSize = orthogonalSize;
1047
1109
  if (!this.proportions) {
1048
- const indexes = range(this.views.length);
1049
- const lowPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.Low);
1050
- const highPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.High);
1051
- this.resize(this.views.length - 1, size - previousSize, undefined, lowPriorityIndexes, highPriorityIndexes);
1110
+ const indexes = range(this.viewItems.length);
1111
+ const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
1112
+ const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
1113
+ this.resize(this.viewItems.length - 1, size - previousSize, undefined, lowPriorityIndexes, highPriorityIndexes);
1052
1114
  }
1053
1115
  else {
1054
- for (let i = 0; i < this.views.length; i++) {
1055
- const item = this.views[i];
1116
+ for (let i = 0; i < this.viewItems.length; i++) {
1117
+ const item = this.viewItems[i];
1056
1118
  item.size = clamp(Math.round(this.proportions[i] * size), item.minimumSize, item.maximumSize);
1057
1119
  }
1058
1120
  }
@@ -1060,18 +1122,18 @@ class Splitview {
1060
1122
  this.layoutViews();
1061
1123
  }
1062
1124
  relayout(lowPriorityIndexes, highPriorityIndexes) {
1063
- const contentSize = this.views.reduce((r, i) => r + i.size, 0);
1064
- this.resize(this.views.length - 1, this._size - contentSize, undefined, lowPriorityIndexes, highPriorityIndexes);
1125
+ const contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
1126
+ this.resize(this.viewItems.length - 1, this._size - contentSize, undefined, lowPriorityIndexes, highPriorityIndexes);
1065
1127
  this.distributeEmptySpace();
1066
1128
  this.layoutViews();
1067
1129
  this.saveProportions();
1068
1130
  }
1069
1131
  distributeEmptySpace(lowPriorityIndex) {
1070
- const contentSize = this.views.reduce((r, i) => r + i.size, 0);
1132
+ const contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
1071
1133
  let emptyDelta = this.size - contentSize;
1072
- const indexes = range(this.views.length - 1, -1);
1073
- const lowPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.Low);
1074
- const highPriorityIndexes = indexes.filter((i) => this.views[i].priority === exports.LayoutPriority.High);
1134
+ const indexes = range(this.viewItems.length - 1, -1);
1135
+ const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
1136
+ const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
1075
1137
  for (const index of highPriorityIndexes) {
1076
1138
  pushToStart(indexes, index);
1077
1139
  }
@@ -1082,7 +1144,7 @@ class Splitview {
1082
1144
  pushToEnd(indexes, lowPriorityIndex);
1083
1145
  }
1084
1146
  for (let i = 0; emptyDelta !== 0 && i < indexes.length; i++) {
1085
- const item = this.views[indexes[i]];
1147
+ const item = this.viewItems[indexes[i]];
1086
1148
  const size = clamp(item.size + emptyDelta, item.minimumSize, item.maximumSize);
1087
1149
  const viewDelta = size - item.size;
1088
1150
  emptyDelta -= viewDelta;
@@ -1091,16 +1153,16 @@ class Splitview {
1091
1153
  }
1092
1154
  saveProportions() {
1093
1155
  if (this.proportionalLayout && this.contentSize > 0) {
1094
- this._proportions = this.views.map((i) => i.size / this.contentSize);
1156
+ this._proportions = this.viewItems.map((i) => i.size / this.contentSize);
1095
1157
  }
1096
1158
  }
1097
1159
  layoutViews() {
1098
- this.contentSize = this.views.reduce((r, i) => r + i.size, 0);
1160
+ this.contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
1099
1161
  let sum = 0;
1100
1162
  const x = [];
1101
1163
  this.updateSashEnablement();
1102
- for (let i = 0; i < this.views.length - 1; i++) {
1103
- sum += this.views[i].size;
1164
+ for (let i = 0; i < this.viewItems.length - 1; i++) {
1165
+ sum += this.viewItems[i].size;
1104
1166
  x.push(sum);
1105
1167
  const offset = Math.min(Math.max(0, sum - 2), this.size - 4);
1106
1168
  if (this._orientation === exports.Orientation.HORIZONTAL) {
@@ -1112,7 +1174,7 @@ class Splitview {
1112
1174
  this.sashes[i].container.style.top = `${offset}px`;
1113
1175
  }
1114
1176
  }
1115
- this.views.forEach((view, i) => {
1177
+ this.viewItems.forEach((view, i) => {
1116
1178
  if (this._orientation === exports.Orientation.HORIZONTAL) {
1117
1179
  view.container.style.width = `${view.size}px`;
1118
1180
  view.container.style.left = i == 0 ? '0px' : `${x[i - 1]}px`;
@@ -1131,7 +1193,7 @@ class Splitview {
1131
1193
  findFirstSnapIndex(indexes) {
1132
1194
  // visible views first
1133
1195
  for (const index of indexes) {
1134
- const viewItem = this.views[index];
1196
+ const viewItem = this.viewItems[index];
1135
1197
  if (!viewItem.visible) {
1136
1198
  continue;
1137
1199
  }
@@ -1141,7 +1203,7 @@ class Splitview {
1141
1203
  }
1142
1204
  // then, hidden views
1143
1205
  for (const index of indexes) {
1144
- const viewItem = this.views[index];
1206
+ const viewItem = this.viewItems[index];
1145
1207
  if (viewItem.visible &&
1146
1208
  viewItem.maximumSize - viewItem.minimumSize > 0) {
1147
1209
  return undefined;
@@ -1154,10 +1216,10 @@ class Splitview {
1154
1216
  }
1155
1217
  updateSashEnablement() {
1156
1218
  let previous = false;
1157
- const collapsesDown = this.views.map((i) => (previous = i.size - i.minimumSize > 0 || previous));
1219
+ const collapsesDown = this.viewItems.map((i) => (previous = i.size - i.minimumSize > 0 || previous));
1158
1220
  previous = false;
1159
- const expandsDown = this.views.map((i) => (previous = i.maximumSize - i.size > 0 || previous));
1160
- const reverseViews = [...this.views].reverse();
1221
+ const expandsDown = this.viewItems.map((i) => (previous = i.maximumSize - i.size > 0 || previous));
1222
+ const reverseViews = [...this.viewItems].reverse();
1161
1223
  previous = false;
1162
1224
  const collapsesUp = reverseViews
1163
1225
  .map((i) => (previous = i.size - i.minimumSize > 0 || previous))
@@ -1169,19 +1231,19 @@ class Splitview {
1169
1231
  let position = 0;
1170
1232
  for (let index = 0; index < this.sashes.length; index++) {
1171
1233
  const sash = this.sashes[index];
1172
- const viewItem = this.views[index];
1234
+ const viewItem = this.viewItems[index];
1173
1235
  position += viewItem.size;
1174
1236
  const min = !(collapsesDown[index] && expandsUp[index + 1]);
1175
1237
  const max = !(expandsDown[index] && collapsesUp[index + 1]);
1176
1238
  if (min && max) {
1177
1239
  const upIndexes = range(index, -1);
1178
- const downIndexes = range(index + 1, this.views.length);
1240
+ const downIndexes = range(index + 1, this.viewItems.length);
1179
1241
  const snapBeforeIndex = this.findFirstSnapIndex(upIndexes);
1180
1242
  const snapAfterIndex = this.findFirstSnapIndex(downIndexes);
1181
1243
  const snappedBefore = typeof snapBeforeIndex === 'number' &&
1182
- !this.views[snapBeforeIndex].visible;
1244
+ !this.viewItems[snapBeforeIndex].visible;
1183
1245
  const snappedAfter = typeof snapAfterIndex === 'number' &&
1184
- !this.views[snapAfterIndex].visible;
1246
+ !this.viewItems[snapAfterIndex].visible;
1185
1247
  if (snappedBefore &&
1186
1248
  collapsesUp[index] &&
1187
1249
  (position > 0 || this.startSnappingEnabled)) {
@@ -1241,6 +1303,9 @@ class Splitview {
1241
1303
  break;
1242
1304
  }
1243
1305
  }
1306
+ for (const viewItem of this.viewItems) {
1307
+ viewItem.dispose();
1308
+ }
1244
1309
  this.element.remove();
1245
1310
  }
1246
1311
  }
@@ -1675,7 +1740,7 @@ class BranchNode extends CompositeDisposable {
1675
1740
  throw new Error('Invalid index');
1676
1741
  }
1677
1742
  this.splitview.removeView(index, sizing);
1678
- this._removeChild(index);
1743
+ return this._removeChild(index);
1679
1744
  }
1680
1745
  _addChild(node, index) {
1681
1746
  this.children.splice(index, 0, node);
@@ -1697,10 +1762,10 @@ class BranchNode extends CompositeDisposable {
1697
1762
  });
1698
1763
  }
1699
1764
  dispose() {
1700
- super.dispose();
1701
1765
  this._childrenDisposable.dispose();
1702
- this.children.forEach((child) => child.dispose());
1703
1766
  this.splitview.dispose();
1767
+ this.children.forEach((child) => child.dispose());
1768
+ super.dispose();
1704
1769
  }
1705
1770
  }
1706
1771
 
@@ -1930,7 +1995,8 @@ class Gridview {
1930
1995
  if (oldRoot.children.length === 1) {
1931
1996
  // can remove one level of redundant branching if there is only a single child
1932
1997
  const childReference = oldRoot.children[0];
1933
- oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
1998
+ const child = oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
1999
+ child.dispose();
1934
2000
  oldRoot.dispose();
1935
2001
  this._root.addChild(
1936
2002
  /**
@@ -2037,7 +2103,8 @@ class Gridview {
2037
2103
  if (typeof newSiblingCachedVisibleSize === 'number') {
2038
2104
  newSiblingSize = exports.Sizing.Invisible(newSiblingCachedVisibleSize);
2039
2105
  }
2040
- grandParent.removeChild(parentIndex);
2106
+ const child = grandParent.removeChild(parentIndex);
2107
+ child.dispose();
2041
2108
  const newParent = new BranchNode(parent.orientation, this.proportionalLayout, this.styles, parent.size, parent.orthogonalSize);
2042
2109
  grandParent.addChild(newParent, parent.size, parentIndex);
2043
2110
  const newSibling = new LeafNode(parent.view, grandParent.orientation, parent.size);
@@ -2063,30 +2130,36 @@ class Gridview {
2063
2130
  if (!(node instanceof LeafNode)) {
2064
2131
  throw new Error('Invalid location');
2065
2132
  }
2066
- parent.removeChild(index, sizing);
2133
+ const view = node.view;
2134
+ node.dispose(); // dispose of node
2135
+ const child = parent.removeChild(index, sizing);
2136
+ child.dispose();
2067
2137
  if (parent.children.length === 0) {
2068
- return node.view;
2138
+ return view;
2069
2139
  }
2070
2140
  if (parent.children.length > 1) {
2071
- return node.view;
2141
+ return view;
2072
2142
  }
2073
2143
  const sibling = parent.children[0];
2074
2144
  if (pathToParent.length === 0) {
2075
2145
  // parent is root
2076
2146
  if (sibling instanceof LeafNode) {
2077
- return node.view;
2147
+ return view;
2078
2148
  }
2079
2149
  // we must promote sibling to be the new root
2080
- parent.removeChild(0, sizing);
2150
+ const child = parent.removeChild(0, sizing);
2151
+ child.dispose();
2081
2152
  this.root = sibling;
2082
- return node.view;
2153
+ return view;
2083
2154
  }
2084
2155
  const [grandParent, ..._] = [...pathToParent].reverse();
2085
2156
  const [parentIndex, ...__] = [...rest].reverse();
2086
2157
  const isSiblingVisible = parent.isChildVisible(0);
2087
- parent.removeChild(0, sizing);
2158
+ const childNode = parent.removeChild(0, sizing);
2159
+ childNode.dispose();
2088
2160
  const sizes = grandParent.children.map((_size, i) => grandParent.getChildSize(i));
2089
- grandParent.removeChild(parentIndex, sizing);
2161
+ const parentNode = grandParent.removeChild(parentIndex, sizing);
2162
+ parentNode.dispose();
2090
2163
  if (sibling instanceof BranchNode) {
2091
2164
  sizes.splice(parentIndex, 1, ...sibling.children.map((c) => c.size));
2092
2165
  for (let i = 0; i < sibling.children.length; i++) {
@@ -2104,7 +2177,7 @@ class Gridview {
2104
2177
  for (let i = 0; i < sizes.length; i++) {
2105
2178
  grandParent.resizeChild(i, sizes[i]);
2106
2179
  }
2107
- return node.view;
2180
+ return view;
2108
2181
  }
2109
2182
  layout(width, height) {
2110
2183
  const [size, orthogonalSize] = this.root.orientation === exports.Orientation.HORIZONTAL
@@ -2599,6 +2672,7 @@ class Droptarget extends CompositeDisposable {
2599
2672
  }
2600
2673
  dispose() {
2601
2674
  this.removeDropTarget();
2675
+ super.dispose();
2602
2676
  }
2603
2677
  toggleClasses(quadrant, width, height) {
2604
2678
  var _a, _b, _c, _d;
@@ -2776,8 +2850,8 @@ class ContentContainer extends CompositeDisposable {
2776
2850
  if (this.panel.view) {
2777
2851
  const _onDidFocus = this.panel.view.content.onDidFocus;
2778
2852
  const _onDidBlur = this.panel.view.content.onDidBlur;
2779
- const { onDidFocus, onDidBlur } = trackFocus(this._element);
2780
- disposable.addDisposables(onDidFocus(() => this._onDidFocus.fire()), onDidBlur(() => this._onDidBlur.fire()));
2853
+ const focusTracker = trackFocus(this._element);
2854
+ disposable.addDisposables(focusTracker, focusTracker.onDidFocus(() => this._onDidFocus.fire()), focusTracker.onDidBlur(() => this._onDidBlur.fire()));
2781
2855
  if (_onDidFocus) {
2782
2856
  disposable.addDisposables(_onDidFocus(() => this._onDidFocus.fire()));
2783
2857
  }
@@ -2820,6 +2894,7 @@ class DragHandler extends CompositeDisposable {
2820
2894
  this._onDragStart = new Emitter();
2821
2895
  this.onDragStart = this._onDragStart.event;
2822
2896
  this.iframes = [];
2897
+ this.addDisposables(this._onDragStart);
2823
2898
  this.configure();
2824
2899
  }
2825
2900
  configure() {
@@ -2870,13 +2945,12 @@ class Tab extends CompositeDisposable {
2870
2945
  this.onChanged = this._onChanged.event;
2871
2946
  this._onDropped = new Emitter();
2872
2947
  this.onDrop = this._onDropped.event;
2873
- this.addDisposables(this._onChanged, this._onDropped);
2874
2948
  this._element = document.createElement('div');
2875
2949
  this._element.className = 'tab';
2876
2950
  this._element.tabIndex = 0;
2877
2951
  this._element.draggable = true;
2878
2952
  toggleClass(this.element, 'inactive-tab', true);
2879
- this.addDisposables(new (class Handler extends DragHandler {
2953
+ this.addDisposables(this._onChanged, this._onDropped, new (class Handler extends DragHandler {
2880
2954
  constructor() {
2881
2955
  super(...arguments);
2882
2956
  this.panelTransfer = LocalSelectionTransfer.getInstance();
@@ -2889,9 +2963,6 @@ class Tab extends CompositeDisposable {
2889
2963
  },
2890
2964
  };
2891
2965
  }
2892
- dispose() {
2893
- //
2894
- }
2895
2966
  })(this._element));
2896
2967
  this.addDisposables(addDisposableListener(this._element, 'mousedown', (event) => {
2897
2968
  if (event.defaultPrevented) {
@@ -2926,7 +2997,7 @@ class Tab extends CompositeDisposable {
2926
2997
  });
2927
2998
  this.addDisposables(this.droptarget.onDrop((event) => {
2928
2999
  this._onDropped.fire(event);
2929
- }));
3000
+ }), this.droptarget);
2930
3001
  }
2931
3002
  setActive(isActive) {
2932
3003
  toggleClass(this.element, 'active-tab', isActive);
@@ -2941,7 +3012,6 @@ class Tab extends CompositeDisposable {
2941
3012
  }
2942
3013
  dispose() {
2943
3014
  super.dispose();
2944
- this.droptarget.dispose();
2945
3015
  }
2946
3016
  }
2947
3017
 
@@ -2987,9 +3057,6 @@ class GroupDragHandler extends DragHandler {
2987
3057
  },
2988
3058
  };
2989
3059
  }
2990
- dispose() {
2991
- //
2992
- }
2993
3060
  }
2994
3061
 
2995
3062
  class VoidContainer extends CompositeDisposable {
@@ -3145,6 +3212,7 @@ class TabsContainer extends CompositeDisposable {
3145
3212
  const tabToRemove = this.tabs.splice(index, 1)[0];
3146
3213
  const { value, disposable } = tabToRemove;
3147
3214
  disposable.dispose();
3215
+ value.dispose();
3148
3216
  value.element.remove();
3149
3217
  }
3150
3218
  setActivePanel(panel) {
@@ -3188,9 +3256,10 @@ class TabsContainer extends CompositeDisposable {
3188
3256
  }
3189
3257
  dispose() {
3190
3258
  super.dispose();
3191
- this.tabs.forEach((tab) => {
3192
- tab.disposable.dispose();
3193
- });
3259
+ for (const { value, disposable } of this.tabs) {
3260
+ disposable.dispose();
3261
+ value.dispose();
3262
+ }
3194
3263
  this.tabs = [];
3195
3264
  }
3196
3265
  }
@@ -3288,7 +3357,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
3288
3357
  container.append(this.tabsContainer.element, this.contentContainer.element);
3289
3358
  this.header.hidden = !!options.hideHeader;
3290
3359
  this.locked = !!options.locked;
3291
- this.addDisposables(this._onMove, this._onDidChange, this._onDidDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this.tabsContainer.onDrop((event) => {
3360
+ this.addDisposables(this.tabsContainer.onDrop((event) => {
3292
3361
  this.handleDropEvent(event.event, 'center', event.index);
3293
3362
  }), this.contentContainer.onDidFocus(() => {
3294
3363
  this.accessor.doSetGroupActive(this.groupPanel, true);
@@ -3296,7 +3365,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
3296
3365
  // noop
3297
3366
  }), this.dropTarget.onDrop((event) => {
3298
3367
  this.handleDropEvent(event.nativeEvent, event.position);
3299
- }));
3368
+ }), this._onMove, this._onDidChange, this._onDidDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange);
3300
3369
  }
3301
3370
  initialize() {
3302
3371
  var _a, _b;
@@ -3730,8 +3799,7 @@ class BaseGrid extends Resizable {
3730
3799
  this.layout(0, 0, true); // set some elements height/widths
3731
3800
  this.addDisposables(this.gridview.onDidChange(() => {
3732
3801
  this._bufferOnDidLayoutChange.fire();
3733
- }));
3734
- this.addDisposables(exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
3802
+ }), exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
3735
3803
  this._bufferOnDidLayoutChange.fire();
3736
3804
  }), this._bufferOnDidLayoutChange.onEvent(() => {
3737
3805
  this._onDidLayoutChange.fire();
@@ -3834,7 +3902,6 @@ class BaseGrid extends Resizable {
3834
3902
  this.gridview.layout(width, height);
3835
3903
  }
3836
3904
  dispose() {
3837
- super.dispose();
3838
3905
  this._onDidActiveGroupChange.dispose();
3839
3906
  this._onDidAddGroup.dispose();
3840
3907
  this._onDidRemoveGroup.dispose();
@@ -3843,6 +3910,7 @@ class BaseGrid extends Resizable {
3843
3910
  group.dispose();
3844
3911
  }
3845
3912
  this.gridview.dispose();
3913
+ super.dispose();
3846
3914
  }
3847
3915
  }
3848
3916
 
@@ -3906,7 +3974,7 @@ class PanelApiImpl extends CompositeDisposable {
3906
3974
  //
3907
3975
  this._onUpdateParameters = new Emitter();
3908
3976
  this.onUpdateParameters = this._onUpdateParameters.event;
3909
- this.addDisposables(this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onFocusEvent, this._onActiveChange, this._onVisibilityChange, this._onUpdateParameters, this.onDidFocusChange((event) => {
3977
+ this.addDisposables(this.onDidFocusChange((event) => {
3910
3978
  this._isFocused = event.isFocused;
3911
3979
  }), this.onDidActiveChange((event) => {
3912
3980
  this._isActive = event.isActive;
@@ -3915,14 +3983,12 @@ class PanelApiImpl extends CompositeDisposable {
3915
3983
  }), this.onDidDimensionsChange((event) => {
3916
3984
  this._width = event.width;
3917
3985
  this._height = event.height;
3918
- }));
3986
+ }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onFocusEvent, this._onActiveChange, this._onVisibilityChange, this._onUpdateParameters);
3919
3987
  }
3920
3988
  initialize(panel) {
3921
3989
  this.panelUpdatesDisposable.value = this._onUpdateParameters.event((parameters) => {
3922
3990
  panel.update({
3923
- params: {
3924
- params: parameters,
3925
- },
3991
+ params: parameters,
3926
3992
  });
3927
3993
  });
3928
3994
  }
@@ -4017,12 +4083,12 @@ class BasePanelView extends CompositeDisposable {
4017
4083
  this._element.style.height = '100%';
4018
4084
  this._element.style.width = '100%';
4019
4085
  this._element.style.overflow = 'hidden';
4020
- const { onDidFocus, onDidBlur } = trackFocus(this._element);
4021
- this.addDisposables(this.api, onDidFocus(() => {
4086
+ const focusTracker = trackFocus(this._element);
4087
+ this.addDisposables(this.api, focusTracker.onDidFocus(() => {
4022
4088
  this.api._onDidChangeFocus.fire({ isFocused: true });
4023
- }), onDidBlur(() => {
4089
+ }), focusTracker.onDidBlur(() => {
4024
4090
  this.api._onDidChangeFocus.fire({ isFocused: false });
4025
- }));
4091
+ }), focusTracker);
4026
4092
  }
4027
4093
  focus() {
4028
4094
  this.api._onFocusEvent.fire();
@@ -4043,7 +4109,18 @@ class BasePanelView extends CompositeDisposable {
4043
4109
  }
4044
4110
  update(event) {
4045
4111
  var _a, _b;
4112
+ // merge the new parameters with the existing parameters
4046
4113
  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) });
4114
+ /**
4115
+ * delete new keys that have a value of undefined,
4116
+ * allow values of null
4117
+ */
4118
+ for (const key of Object.keys(event.params)) {
4119
+ if (event.params[key] === undefined) {
4120
+ delete this._params.params[key];
4121
+ }
4122
+ }
4123
+ // update the view with the updated props
4047
4124
  (_b = this.part) === null || _b === void 0 ? void 0 : _b.update({ params: this._params.params });
4048
4125
  }
4049
4126
  toJSON() {
@@ -4057,9 +4134,9 @@ class BasePanelView extends CompositeDisposable {
4057
4134
  }
4058
4135
  dispose() {
4059
4136
  var _a;
4060
- super.dispose();
4061
4137
  this.api.dispose();
4062
4138
  (_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
4139
+ super.dispose();
4063
4140
  }
4064
4141
  }
4065
4142
 
@@ -4438,7 +4515,7 @@ class GridviewPanel extends BasePanelView {
4438
4515
  this._maximumHeight = options.maximumHeight;
4439
4516
  }
4440
4517
  this.api.initialize(this); // TODO: required to by-pass 'super before this' requirement
4441
- this.addDisposables(this._onDidChange, this.api.onVisibilityChange((event) => {
4518
+ this.addDisposables(this.api.onVisibilityChange((event) => {
4442
4519
  const { isVisible } = event;
4443
4520
  const { accessor } = this._params;
4444
4521
  accessor.setVisible(this, isVisible);
@@ -4467,7 +4544,7 @@ class GridviewPanel extends BasePanelView {
4467
4544
  height: event.height,
4468
4545
  width: event.width,
4469
4546
  });
4470
- }));
4547
+ }), this._onDidChange);
4471
4548
  }
4472
4549
  setVisible(isVisible) {
4473
4550
  this.api._onDidVisibilityChange.fire({ isVisible });
@@ -4624,7 +4701,7 @@ class DockviewPanelApiImpl extends GridviewPanelApiImpl {
4624
4701
  this.addDisposables(this.disposable, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange);
4625
4702
  }
4626
4703
  setTitle(title) {
4627
- this.panel.update({ params: { title } });
4704
+ this.panel.setTitle(title);
4628
4705
  }
4629
4706
  close() {
4630
4707
  this.group.model.closePanel(this.panel);
@@ -4646,7 +4723,6 @@ class DockviewPanel extends CompositeDisposable {
4646
4723
  this.id = id;
4647
4724
  this.containerApi = containerApi;
4648
4725
  this.view = view;
4649
- this._title = '';
4650
4726
  this._group = group;
4651
4727
  this.api = new DockviewPanelApiImpl(this, this._group);
4652
4728
  this.addDisposables(this.api.onActiveChange(() => {
@@ -4659,8 +4735,8 @@ class DockviewPanel extends CompositeDisposable {
4659
4735
  }
4660
4736
  init(params) {
4661
4737
  this._params = params.params;
4662
- this.setTitle(params.title);
4663
4738
  this.view.init(Object.assign(Object.assign({}, params), { api: this.api, containerApi: this.containerApi }));
4739
+ this.setTitle(params.title);
4664
4740
  }
4665
4741
  focus() {
4666
4742
  this.api._onFocusEvent.fire();
@@ -4677,11 +4753,10 @@ class DockviewPanel extends CompositeDisposable {
4677
4753
  };
4678
4754
  }
4679
4755
  setTitle(title) {
4680
- var _a, _b;
4681
- const didTitleChange = title !== ((_a = this._params) === null || _a === void 0 ? void 0 : _a.title);
4756
+ const didTitleChange = title !== this.title;
4682
4757
  if (didTitleChange) {
4683
4758
  this._title = title;
4684
- (_b = this.view) === null || _b === void 0 ? void 0 : _b.update({
4759
+ this.view.update({
4685
4760
  params: {
4686
4761
  params: this._params,
4687
4762
  title: this.title,
@@ -4691,14 +4766,19 @@ class DockviewPanel extends CompositeDisposable {
4691
4766
  }
4692
4767
  }
4693
4768
  update(event) {
4694
- var _a;
4695
- const params = event.params;
4696
- this._params = Object.assign(Object.assign({}, (this._params || {})), event.params.params);
4697
- if (params.title !== this.title) {
4698
- this._title = params.title;
4699
- this.api._onDidTitleChange.fire({ title: this.title });
4769
+ // merge the new parameters with the existing parameters
4770
+ this._params = Object.assign(Object.assign({}, (this._params || {})), event.params);
4771
+ /**
4772
+ * delete new keys that have a value of undefined,
4773
+ * allow values of null
4774
+ */
4775
+ for (const key of Object.keys(event.params)) {
4776
+ if (event.params[key] === undefined) {
4777
+ delete this._params[key];
4778
+ }
4700
4779
  }
4701
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.update({
4780
+ // update the view with the updated props
4781
+ this.view.update({
4702
4782
  params: {
4703
4783
  params: this._params,
4704
4784
  title: this.title,
@@ -5073,7 +5153,7 @@ class DockviewComponent extends BaseGrid {
5073
5153
  size: { type: 'pixels', value: 20 },
5074
5154
  },
5075
5155
  });
5076
- this.addDisposables(dropTarget, dropTarget.onDrop((event) => {
5156
+ this.addDisposables(dropTarget.onDrop((event) => {
5077
5157
  const data = getPanelData();
5078
5158
  if (data) {
5079
5159
  this.moveGroupOrPanel(this.orthogonalize(event.position), data.groupId, data.panelId || undefined, 'center');
@@ -5081,7 +5161,7 @@ class DockviewComponent extends BaseGrid {
5081
5161
  else {
5082
5162
  this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api, group: null, getData: getPanelData }));
5083
5163
  }
5084
- }));
5164
+ }), dropTarget);
5085
5165
  this._api = new DockviewApi(this);
5086
5166
  this.updateWatermark();
5087
5167
  }
@@ -5405,31 +5485,33 @@ class DockviewComponent extends BaseGrid {
5405
5485
  }
5406
5486
  super.doRemoveGroup(group, { skipActive });
5407
5487
  }
5408
- moveGroupOrPanel(referenceGroup, groupId, itemId, target, index) {
5488
+ moveGroupOrPanel(destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
5409
5489
  var _a;
5410
- const sourceGroup = groupId
5411
- ? (_a = this._groups.get(groupId)) === null || _a === void 0 ? void 0 : _a.value
5490
+ const sourceGroup = sourceGroupId
5491
+ ? (_a = this._groups.get(sourceGroupId)) === null || _a === void 0 ? void 0 : _a.value
5412
5492
  : undefined;
5413
- if (itemId === undefined) {
5493
+ if (sourceItemId === undefined) {
5414
5494
  if (sourceGroup) {
5415
- this.moveGroup(sourceGroup, referenceGroup, target);
5495
+ this.moveGroup(sourceGroup, destinationGroup, destinationTarget);
5416
5496
  }
5417
5497
  return;
5418
5498
  }
5419
- if (!target || target === 'center') {
5420
- const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(itemId)) ||
5421
- this.panels.find((panel) => panel.id === itemId);
5499
+ if (!destinationTarget || destinationTarget === 'center') {
5500
+ const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
5501
+ this.panels.find((panel) => panel.id === sourceItemId);
5422
5502
  if (!groupItem) {
5423
- throw new Error(`No panel with id ${itemId}`);
5503
+ throw new Error(`No panel with id ${sourceItemId}`);
5424
5504
  }
5425
5505
  if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
5426
5506
  this.doRemoveGroup(sourceGroup);
5427
5507
  }
5428
- referenceGroup.model.openPanel(groupItem, { index });
5508
+ destinationGroup.model.openPanel(groupItem, {
5509
+ index: destinationIndex,
5510
+ });
5429
5511
  }
5430
5512
  else {
5431
- const referenceLocation = getGridLocation(referenceGroup.element);
5432
- const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
5513
+ const referenceLocation = getGridLocation(destinationGroup.element);
5514
+ const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
5433
5515
  if (sourceGroup && sourceGroup.size < 2) {
5434
5516
  const [targetParentLocation, to] = tail(targetLocation);
5435
5517
  const sourceLocation = getGridLocation(sourceGroup.element);
@@ -5447,18 +5529,18 @@ class DockviewComponent extends BaseGrid {
5447
5529
  skipDispose: true,
5448
5530
  });
5449
5531
  // after deleting the group we need to re-evaulate the ref location
5450
- const updatedReferenceLocation = getGridLocation(referenceGroup.element);
5451
- const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, target);
5532
+ const updatedReferenceLocation = getGridLocation(destinationGroup.element);
5533
+ const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
5452
5534
  this.doAddGroup(targetGroup, location);
5453
5535
  }
5454
5536
  }
5455
5537
  else {
5456
- const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(itemId)) ||
5457
- this.panels.find((panel) => panel.id === itemId);
5538
+ const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
5539
+ this.panels.find((panel) => panel.id === sourceItemId);
5458
5540
  if (!groupItem) {
5459
- throw new Error(`No panel with id ${itemId}`);
5541
+ throw new Error(`No panel with id ${sourceItemId}`);
5460
5542
  }
5461
- const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
5543
+ const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
5462
5544
  const group = this.createGroupAtLocation(dropLocation);
5463
5545
  group.model.openPanel(groupItem);
5464
5546
  }
@@ -5552,11 +5634,11 @@ class DockviewComponent extends BaseGrid {
5552
5634
  return (_a = Array.from(this._groups.values()).find((group) => group.value.model.containsPanel(panel))) === null || _a === void 0 ? void 0 : _a.value;
5553
5635
  }
5554
5636
  dispose() {
5555
- super.dispose();
5556
5637
  this._onDidActivePanelChange.dispose();
5557
5638
  this._onDidAddPanel.dispose();
5558
5639
  this._onDidRemovePanel.dispose();
5559
5640
  this._onDidLayoutFromJSON.dispose();
5641
+ super.dispose();
5560
5642
  }
5561
5643
  }
5562
5644
 
@@ -5814,7 +5896,7 @@ class SplitviewComponent extends Resizable {
5814
5896
  }
5815
5897
  set splitview(value) {
5816
5898
  this._splitview = value;
5817
- this._disposable.value = new CompositeDisposable(this._splitview.onDidSashEnd(() => {
5899
+ this._splitviewChangeDisposable.value = new CompositeDisposable(this._splitview.onDidSashEnd(() => {
5818
5900
  this._onDidLayoutChange.fire(undefined);
5819
5901
  }), this._splitview.onDidAddView((e) => this._onDidAddView.fire(e)), this._splitview.onDidRemoveView((e) => this._onDidRemoveView.fire(e)));
5820
5902
  }
@@ -5836,7 +5918,7 @@ class SplitviewComponent extends Resizable {
5836
5918
  }
5837
5919
  constructor(options) {
5838
5920
  super(options.parentElement);
5839
- this._disposable = new MutableDisposable();
5921
+ this._splitviewChangeDisposable = new MutableDisposable();
5840
5922
  this._panels = new Map();
5841
5923
  this._onDidLayoutfromJSON = new Emitter();
5842
5924
  this.onDidLayoutFromJSON = this._onDidLayoutfromJSON.event;
@@ -5854,7 +5936,7 @@ class SplitviewComponent extends Resizable {
5854
5936
  options.frameworkComponents = {};
5855
5937
  }
5856
5938
  this.splitview = new Splitview(this.element, options);
5857
- this.addDisposables(this._disposable, this._onDidAddView, this._onDidLayoutfromJSON, this._onDidRemoveView, this._onDidLayoutChange);
5939
+ this.addDisposables(this._onDidAddView, this._onDidLayoutfromJSON, this._onDidRemoveView, this._onDidLayoutChange);
5858
5940
  }
5859
5941
  updateOptions(options) {
5860
5942
  const hasOrientationChanged = typeof options.orientation === 'string' &&
@@ -5892,15 +5974,15 @@ class SplitviewComponent extends Resizable {
5892
5974
  }
5893
5975
  }
5894
5976
  removePanel(panel, sizing) {
5895
- const disposable = this._panels.get(panel.id);
5896
- if (!disposable) {
5977
+ const item = this._panels.get(panel.id);
5978
+ if (!item) {
5897
5979
  throw new Error(`unknown splitview panel ${panel.id}`);
5898
5980
  }
5899
- disposable.disposable.dispose();
5900
- disposable.value.dispose();
5981
+ item.dispose();
5901
5982
  this._panels.delete(panel.id);
5902
5983
  const index = this.panels.findIndex((_) => _ === panel);
5903
- this.splitview.removeView(index, sizing);
5984
+ const removedView = this.splitview.removeView(index, sizing);
5985
+ removedView.dispose();
5904
5986
  const panels = this.panels;
5905
5987
  if (panels.length > 0) {
5906
5988
  this.setActive(panels[panels.length - 1]);
@@ -5947,7 +6029,7 @@ class SplitviewComponent extends Resizable {
5947
6029
  }
5948
6030
  this.setActive(view, true);
5949
6031
  });
5950
- this._panels.set(view.id, { disposable, value: view });
6032
+ this._panels.set(view.id, disposable);
5951
6033
  }
5952
6034
  toJSON() {
5953
6035
  var _a;
@@ -6020,20 +6102,26 @@ class SplitviewComponent extends Resizable {
6020
6102
  this._onDidLayoutfromJSON.fire();
6021
6103
  }
6022
6104
  clear() {
6023
- for (const [_, value] of this._panels.entries()) {
6024
- value.disposable.dispose();
6025
- value.value.dispose();
6105
+ for (const disposable of this._panels.values()) {
6106
+ disposable.dispose();
6026
6107
  }
6027
6108
  this._panels.clear();
6028
- this.splitview.dispose();
6109
+ while (this.splitview.length > 0) {
6110
+ const view = this.splitview.removeView(0, exports.Sizing.Distribute, true);
6111
+ view.dispose();
6112
+ }
6029
6113
  }
6030
6114
  dispose() {
6031
- for (const [_, value] of this._panels.entries()) {
6032
- value.disposable.dispose();
6033
- value.value.dispose();
6115
+ for (const disposable of this._panels.values()) {
6116
+ disposable.dispose();
6034
6117
  }
6035
6118
  this._panels.clear();
6119
+ const views = this.splitview.getViews();
6120
+ this._splitviewChangeDisposable.dispose();
6036
6121
  this.splitview.dispose();
6122
+ for (const view of views) {
6123
+ view.dispose();
6124
+ }
6037
6125
  super.dispose();
6038
6126
  }
6039
6127
  }