@@ -356,6 +356,13 @@ class BranchNode implements ISplitView<ILayoutContext>, IDisposable {
356
356
private _boundarySashes : IRelativeBoundarySashes = { } ;
357
357
get boundarySashes ( ) : IRelativeBoundarySashes { return this . _boundarySashes ; }
358
358
set boundarySashes ( boundarySashes : IRelativeBoundarySashes ) {
359
+ if ( this . _boundarySashes . start === boundarySashes . start
360
+ && this . _boundarySashes . end === boundarySashes . end
361
+ && this . _boundarySashes . orthogonalStart === boundarySashes . orthogonalStart
362
+ && this . _boundarySashes . orthogonalEnd === boundarySashes . orthogonalEnd ) {
363
+ return ;
364
+ }
365
+
359
366
this . _boundarySashes = boundarySashes ;
360
367
361
368
this . splitview . orthogonalStartSash = boundarySashes . orthogonalStart ;
@@ -498,65 +505,20 @@ class BranchNode implements ISplitView<ILayoutContext>, IDisposable {
498
505
index = validateIndex ( index , this . children . length ) ;
499
506
500
507
this . splitview . addView ( node , size , index , skipLayout ) ;
501
- this . _addChild ( node , index ) ;
502
- this . onDidChildrenChange ( ) ;
503
- }
504
-
505
- private _addChild ( node : Node , index : number ) : void {
506
- const first = index === 0 ;
507
- const last = index === this . children . length ;
508
508
this . children . splice ( index , 0 , node ) ;
509
509
510
- node . boundarySashes = {
511
- start : this . boundarySashes . orthogonalStart ,
512
- end : this . boundarySashes . orthogonalEnd ,
513
- orthogonalStart : first ? this . boundarySashes . start : this . splitview . sashes [ index - 1 ] ,
514
- orthogonalEnd : last ? this . boundarySashes . end : this . splitview . sashes [ index ] ,
515
- } ;
516
-
517
- if ( ! first ) {
518
- this . children [ index - 1 ] . boundarySashes = {
519
- ...this . children [ index - 1 ] . boundarySashes ,
520
- orthogonalEnd : this . splitview . sashes [ index - 1 ]
521
- } ;
522
- }
523
-
524
- if ( ! last ) {
525
- this . children [ index + 1 ] . boundarySashes = {
526
- ...this . children [ index + 1 ] . boundarySashes ,
527
- orthogonalStart : this . splitview . sashes [ index ]
528
- } ;
529
- }
510
+ this . updateBoundarySashes ( ) ;
511
+ this . onDidChildrenChange ( ) ;
530
512
}
531
513
532
514
removeChild ( index : number , sizing ?: Sizing ) : void {
533
515
index = validateIndex ( index , this . children . length ) ;
534
516
535
517
this . splitview . removeView ( index , sizing ) ;
536
- this . _removeChild ( index ) ;
537
- this . onDidChildrenChange ( ) ;
538
- }
518
+ this . children . splice ( index , 1 ) ;
539
519
540
- private _removeChild ( index : number ) : Node {
541
- const first = index === 0 ;
542
- const last = index === this . children . length - 1 ;
543
- const [ child ] = this . children . splice ( index , 1 ) ;
544
-
545
- if ( ! first ) {
546
- this . children [ index - 1 ] . boundarySashes = {
547
- ...this . children [ index - 1 ] . boundarySashes ,
548
- orthogonalEnd : this . splitview . sashes [ index - 1 ]
549
- } ;
550
- }
551
-
552
- if ( ! last ) { // [0,1,2,3] (2) => [0,1,3]
553
- this . children [ index ] . boundarySashes = {
554
- ...this . children [ index ] . boundarySashes ,
555
- orthogonalStart : this . splitview . sashes [ Math . max ( index - 1 , 0 ) ]
556
- } ;
557
- }
558
-
559
- return child ;
520
+ this . updateBoundarySashes ( ) ;
521
+ this . onDidChildrenChange ( ) ;
560
522
}
561
523
562
524
moveChild ( from : number , to : number ) : void {
@@ -568,14 +530,13 @@ class BranchNode implements ISplitView<ILayoutContext>, IDisposable {
568
530
}
569
531
570
532
if ( from < to ) {
571
- to -- ;
533
+ to -= 1 ;
572
534
}
573
535
574
536
this . splitview . moveView ( from , to ) ;
537
+ this . children . splice ( to , 0 , this . children . splice ( from , 1 ) [ 0 ] ) ;
575
538
576
- const child = this . _removeChild ( from ) ;
577
- this . _addChild ( child , to ) ;
578
-
539
+ this . updateBoundarySashes ( ) ;
579
540
this . onDidChildrenChange ( ) ;
580
541
}
581
542
@@ -649,6 +610,17 @@ class BranchNode implements ISplitView<ILayoutContext>, IDisposable {
649
610
return this . splitview . getViewCachedVisibleSize ( index ) ;
650
611
}
651
612
613
+ private updateBoundarySashes ( ) : void {
614
+ for ( let i = 0 ; i < this . children . length ; i ++ ) {
615
+ this . children [ i ] . boundarySashes = {
616
+ start : this . boundarySashes . orthogonalStart ,
617
+ end : this . boundarySashes . orthogonalEnd ,
618
+ orthogonalStart : i === 0 ? this . boundarySashes . start : this . splitview . sashes [ i - 1 ] ,
619
+ orthogonalEnd : i === this . children . length - 1 ? this . boundarySashes . end : this . splitview . sashes [ i ] ,
620
+ } ;
621
+ }
622
+ }
623
+
652
624
private onDidChildrenChange ( ) : void {
653
625
this . updateChildrenEvents ( ) ;
654
626
this . _onDidChange . fire ( undefined ) ;
0 commit comments