Skip to content

Commit

Permalink
Use real stats of a tree after all filters
Browse files Browse the repository at this point in the history
  • Loading branch information
swiftyfinch committed May 5, 2024
1 parent a39a536 commit 8c9dad1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
9 changes: 7 additions & 2 deletions Sources/XTreeKit/Common/Tree/TreeFilter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@ final class TreeFilter {
maxHeight: maxHeight
)
}
let children = filteredExplicitChildren.recursiveChildren()
return TreeNode(
icon: tree.icon,
name: tree.name,
info: tree.info,
explicitChildren: filteredExplicitChildren,
children: filteredExplicitChildren.recursiveChildren(),
stats: tree.stats
children: children,
stats: TreeNode.Stats(
height: tree.stats.height,
explicitChildrenCount: filteredExplicitChildren.count,
childrenCount: children.count
)
)
}
}
7 changes: 4 additions & 3 deletions Sources/XTreeKit/Managers/TreeManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,17 @@ extension TreeManager: IInternalTreeManager {
maxHeight: filter.maxHeight
)
}
let children = filteredForest.recursiveChildren()
return TreeNode(
icon: nil,
name: ".",
info: nil,
explicitChildren: filteredForest,
children: filteredForest.recursiveChildren(),
children: children,
stats: TreeNode.Stats(
height: forest.maxHeight(),
explicitChildrenCount: forest.count,
childrenCount: forest.recursiveChildren().count
explicitChildrenCount: filteredForest.count,
childrenCount: children.count
)
)
}
Expand Down

0 comments on commit 8c9dad1

Please sign in to comment.