@@ -325,13 +325,13 @@ export class SplitView extends Disposable {
325325
326326 container . appendChild ( view . element ) ;
327327
328- let highPriorityIndex : number | undefined ;
328+ let highPriorityIndexes : number [ ] | undefined ;
329329
330330 if ( typeof size !== 'number' && size . type === 'split' ) {
331- highPriorityIndex = size . index ;
331+ highPriorityIndexes = [ size . index ] ;
332332 }
333333
334- this . relayout ( index , highPriorityIndex ) ;
334+ this . relayout ( [ index ] , highPriorityIndexes ) ;
335335 this . state = State . Idle ;
336336
337337 if ( typeof size !== 'number' && size . type === 'distribute' ) {
@@ -420,17 +420,6 @@ export class SplitView extends Disposable {
420420 this . layoutViews ( ) ;
421421 }
422422
423- private relayout ( lowPriorityIndex ?: number , highPriorityIndex ?: number ) : void {
424- const contentSize = this . viewItems . reduce ( ( r , i ) => r + i . size , 0 ) ;
425- const lowPriorityIndexes = typeof lowPriorityIndex === 'number' ? [ lowPriorityIndex ] : undefined ;
426- const highPriorityIndexes = typeof highPriorityIndex === 'number' ? [ highPriorityIndex ] : undefined ;
427-
428- this . resize ( this . viewItems . length - 1 , this . size - contentSize , undefined , lowPriorityIndexes , highPriorityIndexes ) ;
429- this . distributeEmptySpace ( ) ;
430- this . layoutViews ( ) ;
431- this . saveProportions ( ) ;
432- }
433-
434423 layout ( size : number ) : void {
435424 const previousSize = Math . max ( this . size , this . contentSize ) ;
436425 this . size = size ;
@@ -582,7 +571,7 @@ export class SplitView extends Disposable {
582571 this . layoutViews ( ) ;
583572 } else {
584573 item . size = size ;
585- this . relayout ( index , undefined ) ;
574+ this . relayout ( [ index ] , undefined ) ;
586575 }
587576 }
588577
@@ -597,42 +586,32 @@ export class SplitView extends Disposable {
597586 return ;
598587 }
599588
589+ const indexes = range ( this . viewItems . length ) . filter ( i => i !== index ) ;
590+ const lowPriorityIndexes = [ ...indexes . filter ( i => this . viewItems [ i ] . priority === LayoutPriority . Low ) , index ] ;
591+ const highPriorityIndexes = indexes . filter ( i => this . viewItems [ i ] . priority === LayoutPriority . High ) ;
592+
600593 const item = this . viewItems [ index ] ;
601594 size = Math . round ( size ) ;
602- size = clamp ( size , item . minimumSize , item . maximumSize ) ;
603- let delta = size - item . size ;
604-
605- if ( delta !== 0 && index < this . viewItems . length - 1 ) {
606- const downIndexes = range ( index + 1 , this . viewItems . length ) ;
607- const collapseDown = downIndexes . reduce ( ( r , i ) => r + ( this . viewItems [ i ] . size - this . viewItems [ i ] . minimumSize ) , 0 ) ;
608- const expandDown = downIndexes . reduce ( ( r , i ) => r + ( this . viewItems [ i ] . maximumSize - this . viewItems [ i ] . size ) , 0 ) ;
609- const deltaDown = clamp ( delta , - expandDown , collapseDown ) ;
610-
611- this . resize ( index , deltaDown ) ;
612- delta -= deltaDown ;
613- }
614-
615- if ( delta !== 0 && index > 0 ) {
616- const upIndexes = range ( index - 1 , - 1 ) ;
617- const collapseUp = upIndexes . reduce ( ( r , i ) => r + ( this . viewItems [ i ] . size - this . viewItems [ i ] . minimumSize ) , 0 ) ;
618- const expandUp = upIndexes . reduce ( ( r , i ) => r + ( this . viewItems [ i ] . maximumSize - this . viewItems [ i ] . size ) , 0 ) ;
619- const deltaUp = clamp ( - delta , - collapseUp , expandUp ) ;
620-
621- this . resize ( index - 1 , deltaUp ) ;
622- }
595+ size = clamp ( size , item . minimumSize , Math . min ( item . maximumSize , this . size ) ) ;
623596
624- this . distributeEmptySpace ( ) ;
625- this . layoutViews ( ) ;
626- this . saveProportions ( ) ;
597+ item . size = size ;
598+ this . relayout ( lowPriorityIndexes , highPriorityIndexes ) ;
627599 this . state = State . Idle ;
628600 }
629601
630602 distributeViewSizes ( ) : void {
631603 const size = Math . floor ( this . size / this . viewItems . length ) ;
632604
633- for ( let i = 0 ; i < this . viewItems . length - 1 ; i ++ ) {
634- this . resizeView ( i , size ) ;
605+ for ( let i = 0 ; i < this . viewItems . length ; i ++ ) {
606+ const item = this . viewItems [ i ] ;
607+ item . size = clamp ( size , item . minimumSize , item . maximumSize ) ;
635608 }
609+
610+ const indexes = range ( this . viewItems . length ) ;
611+ const lowPriorityIndexes = indexes . filter ( i => this . viewItems [ i ] . priority === LayoutPriority . Low ) ;
612+ const highPriorityIndexes = indexes . filter ( i => this . viewItems [ i ] . priority === LayoutPriority . High ) ;
613+
614+ this . relayout ( lowPriorityIndexes , highPriorityIndexes ) ;
636615 }
637616
638617 getViewSize ( index : number ) : number {
@@ -643,6 +622,15 @@ export class SplitView extends Disposable {
643622 return this . viewItems [ index ] . size ;
644623 }
645624
625+ private relayout ( lowPriorityIndexes ?: number [ ] , highPriorityIndexes ?: number [ ] ) : void {
626+ const contentSize = this . viewItems . reduce ( ( r , i ) => r + i . size , 0 ) ;
627+
628+ this . resize ( this . viewItems . length - 1 , this . size - contentSize , undefined , lowPriorityIndexes , highPriorityIndexes ) ;
629+ this . distributeEmptySpace ( ) ;
630+ this . layoutViews ( ) ;
631+ this . saveProportions ( ) ;
632+ }
633+
646634 private resize (
647635 index : number ,
648636 delta : number ,
0 commit comments