提交 5f7e3877 编写于 作者: J Joao Moreno

tree test: setChildren on expanded, unrevealed node

上级 042eef08
......@@ -89,14 +89,11 @@ export class IndexTreeModel<T, TFilterData = void> implements ITreeModel<T, TFil
const lastIndex = location[location.length - 1];
const deletedNodes = parentNode.children.splice(lastIndex, deleteCount, ...nodesToInsert);
if (!parentNode.collapsed) {
if (revealed) {
const visibleDeleteCount = deletedNodes.reduce((r, node) => r + node.revealedCount, 0);
this._updateAncestorsRevealedCount(parentNode, revealedCount - visibleDeleteCount);
if (revealed) {
this.list.splice(listIndex, visibleDeleteCount, treeListElementsToInsert);
}
this.list.splice(listIndex, visibleDeleteCount, treeListElementsToInsert);
}
if (deletedNodes.length > 0 && onDidDeleteNode) {
......
......@@ -114,4 +114,30 @@ suite('ObjectTreeModel', function () {
model.setCollapsed(0, false);
assert.deepEqual(toArray(list), [0, 1, 2]);
});
test('setChildren on expanded, unrevealed node', () => {
const list = [] as ITreeNode<number>[];
const model = new ObjectTreeModel<number>(toSpliceable(list));
model.setChildren(null, [
{
element: 1, collapsed: true, children: [
{ element: 11, collapsed: false }
]
},
{ element: 2 }
]);
assert.deepEqual(toArray(list), [1, 2]);
model.setChildren(11, [
{ element: 111 },
{ element: 112 }
]);
assert.deepEqual(toArray(list), [1, 2]);
model.setCollapsed(1, false);
assert.deepEqual(toArray(list), [1, 11, 111, 112, 2]);
});
});
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册