Skip to content

Commit d2264e3

Browse files
committed
tree: fix visibility not being updated on refilter
Fixes microsoft#133272
1 parent a73b1de commit d2264e3

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/vs/base/browser/ui/tree/indexTreeModel.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ export class IndexTreeModel<T extends Exclude<any, undefined>, TFilterData = voi
633633

634634
if (node !== this.root) {
635635
node.visible = visibility! === TreeVisibility.Recurse ? hasVisibleDescendants : (visibility! === TreeVisibility.Visible);
636+
node.visibility = visibility!;
636637
}
637638

638639
if (!node.visible) {

src/vs/base/test/browser/ui/tree/indexTreeModel.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,40 @@ suite('IndexTreeModel', () => {
659659
assert.deepStrictEqual(toArray(list), ['vscode', '.build', 'github', 'build.js', 'build']);
660660
});
661661

662+
test('recursive filter updates when children change (#133272)', () => {
663+
const list: ITreeNode<string>[] = [];
664+
let query = '';
665+
const filter = new class implements ITreeFilter<string> {
666+
filter(element: string): TreeVisibility {
667+
return element.includes(query) ? TreeVisibility.Visible : TreeVisibility.Recurse;
668+
}
669+
};
670+
671+
const model = new IndexTreeModel<string>('test', toList(list), 'root', { filter });
672+
673+
model.splice([0], 0, [
674+
{
675+
element: 'a',
676+
children: [
677+
{ element: 'b' },
678+
],
679+
},
680+
]);
681+
682+
assert.deepStrictEqual(toArray(list), ['a', 'b']);
683+
query = 'visible';
684+
model.refilter();
685+
assert.deepStrictEqual(toArray(list), []);
686+
687+
model.splice([0, 0, 0], 0, [
688+
{
689+
element: 'visible', children: []
690+
},
691+
]);
692+
693+
assert.deepStrictEqual(toArray(list), ['a', 'b', 'visible']);
694+
});
695+
662696
test('recursive filter with collapse', () => {
663697
const list: ITreeNode<string>[] = [];
664698
let query = new RegExp('');

0 commit comments

Comments
 (0)