@@ -36,6 +36,9 @@ class TestView implements IView<number> {
3636 private readonly _onDidFocus = new Emitter < void > ( ) ;
3737 readonly onDidFocus = this . _onDidFocus . event ;
3838
39+ private readonly _onDidSetVisible = new Emitter < boolean > ( ) ;
40+ readonly onDidSetVisible = this . _onDidSetVisible . event ;
41+
3942 constructor (
4043 private _minimumSize : number ,
4144 private _maximumSize : number ,
@@ -44,6 +47,17 @@ class TestView implements IView<number> {
4447 assert ( _minimumSize <= _maximumSize , 'splitview view minimum size must be <= maximum size' ) ;
4548 }
4649
50+ /** Change both size constraints at once, as a view with a fixed width does when that width changes. */
51+ setSizeConstraints ( minimumSize : number , maximumSize : number ) : void {
52+ this . _minimumSize = minimumSize ;
53+ this . _maximumSize = maximumSize ;
54+ this . _onDidChange . fire ( undefined ) ;
55+ }
56+
57+ setVisible ( visible : boolean ) : void {
58+ this . _onDidSetVisible . fire ( visible ) ;
59+ }
60+
4761 layout ( size : number , _offset : number , orthogonalSize : number | undefined ) : void {
4862 this . _size = size ;
4963 this . _orthogonalSize = orthogonalSize ;
@@ -59,6 +73,7 @@ class TestView implements IView<number> {
5973 this . _onDidGetElement . dispose ( ) ;
6074 this . _onDidLayout . dispose ( ) ;
6175 this . _onDidFocus . dispose ( ) ;
76+ this . _onDidSetVisible . dispose ( ) ;
6277 }
6378}
6479
@@ -459,6 +474,32 @@ suite('Splitview', () => {
459474 assert . deepStrictEqual ( [ view1 . size , view2 . size , view3 . size ] , [ 20 , 160 , 20 ] ) ;
460475 } ) ;
461476
477+ test ( 'view changing its size constraints while a sibling is toggled does not squeeze that sibling (#334167)' , ( ) => {
478+
479+ // Mirrors the workbench with the side bar on the right: the activity bar reports its new fixed width from within the visibility change of the side bar
480+ const editor = store . add ( new TestView ( 20 , Number . POSITIVE_INFINITY , LayoutPriority . High ) ) ;
481+ const sideBar = store . add ( new TestView ( 20 , Number . POSITIVE_INFINITY , LayoutPriority . Low ) ) ;
482+ const activityBar = store . add ( new TestView ( 10 , 10 ) ) ;
483+ const splitview = store . add ( new SplitView ( container , { proportionalLayout : false } ) ) ;
484+ splitview . layout ( 200 ) ;
485+
486+ splitview . addView ( editor , 120 ) ;
487+ splitview . addView ( sideBar , 70 ) ;
488+ splitview . addView ( activityBar , 10 ) ;
489+
490+ // `addView` distributes in index order too, so restore the side bar to a known starting point
491+ splitview . resizeView ( 1 , 70 ) ;
492+ assert . deepStrictEqual ( [ editor . size , sideBar . size , activityBar . size ] , [ 120 , 70 , 10 ] ) ;
493+
494+ store . add ( sideBar . onDidSetVisible ( visible => activityBar . setSizeConstraints ( visible ? 10 : 12 , visible ? 10 : 12 ) ) ) ;
495+
496+ splitview . setViewVisible ( 1 , false ) ;
497+ assert . deepStrictEqual ( [ editor . size , sideBar . size , activityBar . size ] , [ 188 , 0 , 12 ] ) ;
498+
499+ splitview . setViewVisible ( 1 , true ) ;
500+ assert . deepStrictEqual ( [ editor . size , sideBar . size , activityBar . size ] , [ 120 , 70 , 10 ] ) ;
501+ } ) ;
502+
462503 test ( 'context propagates to views' , ( ) => {
463504 const view1 = store . add ( new TestView ( 20 , Number . POSITIVE_INFINITY ) ) ;
464505 const view2 = store . add ( new TestView ( 20 , Number . POSITIVE_INFINITY ) ) ;
0 commit comments