未验证 提交 1bd3750d 编写于 作者: J Joao Moreno

fix #84425

上级 47736a99
......@@ -605,7 +605,7 @@ export type GridNodeDescriptor = { size?: number, groups?: GridNodeDescriptor[]
export type GridDescriptor = { orientation: Orientation, groups?: GridNodeDescriptor[] };
export function sanitizeGridNodeDescriptor(nodeDescriptor: GridNodeDescriptor): void {
if (nodeDescriptor.groups && nodeDescriptor.groups.length === 0) {
if (nodeDescriptor.groups && nodeDescriptor.groups.length <= 1) {
nodeDescriptor.groups = undefined;
}
......
......@@ -7,6 +7,7 @@ import * as assert from 'assert';
import { Direction, getRelativeLocation, Orientation, SerializableGrid, ISerializableView, IViewDeserializer, GridNode, Sizing, isGridBranchNode, sanitizeGridNodeDescriptor, GridNodeDescriptor, createSerializedGrid, Grid } from 'vs/base/browser/ui/grid/grid';
import { TestView, nodesToArrays } from './util';
import { deepClone } from 'vs/base/common/objects';
import { Event } from 'vs/base/common/event';
// Simple example:
//
......@@ -814,6 +815,33 @@ suite('SerializableGrid', function () {
});
});
test('createSerializedGrid - issue #85601, should not allow single children groups', () => {
const serializedGrid = createSerializedGrid({ orientation: Orientation.HORIZONTAL, groups: [{ groups: [{}, {}], size: 0.5 }, { groups: [{}], size: 0.5 }] });
const views: ISerializableView[] = [];
const deserializer = new class implements IViewDeserializer<ISerializableView> {
fromJSON(): ISerializableView {
const view: ISerializableView = {
element: document.createElement('div'),
layout: () => null,
minimumWidth: 0,
maximumWidth: Number.POSITIVE_INFINITY,
minimumHeight: 0,
maximumHeight: Number.POSITIVE_INFINITY,
onDidChange: Event.None,
toJSON: () => ({})
};
views.push(view);
return view;
}
};
const grid = SerializableGrid.deserialize(serializedGrid, deserializer);
assert.equal(views.length, 3);
// should not throw
grid.removeView(views[2]);
});
test('serialize should store visibility and previous size', function () {
const view1 = new TestSerializableView('view1', 50, Number.MAX_VALUE, 50, Number.MAX_VALUE);
const grid = new SerializableGrid(view1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册