@@ -7,6 +7,7 @@ import * as assert from 'assert';
77import { Direction , getRelativeLocation , Orientation , SerializableGrid , ISerializableView , IViewDeserializer , GridNode , Sizing , isGridBranchNode , sanitizeGridNodeDescriptor , GridNodeDescriptor , createSerializedGrid , Grid } from 'vs/base/browser/ui/grid/grid' ;
88import { TestView , nodesToArrays } from './util' ;
99import { deepClone } from 'vs/base/common/objects' ;
10+ import { Event } from 'vs/base/common/event' ;
1011
1112// Simple example:
1213//
@@ -814,6 +815,33 @@ suite('SerializableGrid', function () {
814815 } ) ;
815816 } ) ;
816817
818+ test ( 'createSerializedGrid - issue #85601, should not allow single children groups' , ( ) => {
819+ const serializedGrid = createSerializedGrid ( { orientation : Orientation . HORIZONTAL , groups : [ { groups : [ { } , { } ] , size : 0.5 } , { groups : [ { } ] , size : 0.5 } ] } ) ;
820+ const views : ISerializableView [ ] = [ ] ;
821+ const deserializer = new class implements IViewDeserializer < ISerializableView > {
822+ fromJSON ( ) : ISerializableView {
823+ const view : ISerializableView = {
824+ element : document . createElement ( 'div' ) ,
825+ layout : ( ) => null ,
826+ minimumWidth : 0 ,
827+ maximumWidth : Number . POSITIVE_INFINITY ,
828+ minimumHeight : 0 ,
829+ maximumHeight : Number . POSITIVE_INFINITY ,
830+ onDidChange : Event . None ,
831+ toJSON : ( ) => ( { } )
832+ } ;
833+ views . push ( view ) ;
834+ return view ;
835+ }
836+ } ;
837+
838+ const grid = SerializableGrid . deserialize ( serializedGrid , deserializer ) ;
839+ assert . equal ( views . length , 3 ) ;
840+
841+ // should not throw
842+ grid . removeView ( views [ 2 ] ) ;
843+ } ) ;
844+
817845 test ( 'serialize should store visibility and previous size' , function ( ) {
818846 const view1 = new TestSerializableView ( 'view1' , 50 , Number . MAX_VALUE , 50 , Number . MAX_VALUE ) ;
819847 const grid = new SerializableGrid ( view1 ) ;
0 commit comments