Repository navigation
Draw no ArrowTree connector or bar towards empty nested subtrees - #104
Merged
Merged
Conversation
In a NestedTree an empty subtree takes no line, but ArrowTree asked its own tree for the next sibling and so drew a T-shaped connector and a vertical bar towards it when it was the last entry. ArrowTree now skips siblings that are trees holding nothing but empty trees. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In a
NestedTree, an empty subtree takes no line (#77).ArrowTreedecorates with its own tree's positions, though, and asked that tree for the next sibling, so a node followed only by an empty subtree was drawn with a T-shaped connector, and its descendants with a vertical bar, leading to nothing:ArrowTreenow asks_has_next_sibling, which skips siblings that are trees holding nothing but empty trees, at all four places that decide between├and└or draw a vertical bar (first lines, spacers and continuation lines). Trees without nested empty subtrees are unaffected.The emptiness check is a loop with an explicit stack, so deeply nested empty trees do not hit the recursion limit.
Tests:
test_arrows_skip_empty_subtreescovers the connector, the bar on a grandchild's line and a continuation line, with an empty subtree and a subtree holding only an empty subtree as trailing siblings. It fails without the fix.test_arrows_skip_deeply_nested_empty_subtreedecorates a node followed by an empty tree wrapped 1500 levels deep (decoration only, sinceNestedTreenavigation still recurses once per nesting level, a known limit).Not covered:
CollapsibleArrowTreeandCollapsibleIndentedTreestill draw a collapse icon on a node whose only children are empty subtrees, sincecollapsibleasks the wrapped tree whether the node is a leaf.Review findings and resolution
review-correctness
ponytail:comment. Each check walks the run of empties, so the cost is lines times empties, but only in that shape;NestedTreesibling moves already walk such runs, and the walker's line cache keeps a line from being decorated again until a refresh. A cache inArrowTreewould go stale when the tree changes and has no hook to clear it.NestedTree's navigation instead: left,ArrowTreeis wrapped by theNestedTreeand cannot see it.IndentedTreedraws nothing per sibling; the collapse icon case is listed under "Not covered".review-design
ArrowTreeover a decorated tree is unverified: checked,ArrowTree(CollapsibleTree(...))inside aNestedTreerenders└─➤a, sinceDecoratedTree.__getitem__returns the wrapped entry. No test added, as decorators do not stack (Document that decorators do not stack and CollapseMixin needs a wrapper #98)._is_empty_treeatNestedTree._sanitize_position: done in its docstring.decoration.pythat knows about nested trees: kept, as the reviewer recommends over a public predicate onTree.🤖 Generated with Claude Code