Skip to content

Commit 1bd3750

Browse files
committed
1 parent 47736a9 commit 1bd3750

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

src/vs/base/browser/ui/grid/grid.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ export type GridNodeDescriptor = { size?: number, groups?: GridNodeDescriptor[]
605605
export type GridDescriptor = { orientation: Orientation, groups?: GridNodeDescriptor[] };
606606

607607
export function sanitizeGridNodeDescriptor(nodeDescriptor: GridNodeDescriptor): void {
608-
if (nodeDescriptor.groups && nodeDescriptor.groups.length === 0) {
608+
if (nodeDescriptor.groups && nodeDescriptor.groups.length <= 1) {
609609
nodeDescriptor.groups = undefined;
610610
}
611611

src/vs/base/test/browser/ui/grid/grid.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as assert from 'assert';
77
import { Direction, getRelativeLocation, Orientation, SerializableGrid, ISerializableView, IViewDeserializer, GridNode, Sizing, isGridBranchNode, sanitizeGridNodeDescriptor, GridNodeDescriptor, createSerializedGrid, Grid } from 'vs/base/browser/ui/grid/grid';
88
import { TestView, nodesToArrays } from './util';
99
import { 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

Comments
 (0)