Repository navigation
Compute SimpleTree and TreeListWalker roots on access - #102
Merged
Merged
Conversation
SimpleTree copied its root at construction, so a tree built from an empty list stayed empty after nodes were appended to that list, and TreeListWalker kept its own copy of the tree's root and fixed its initial focus to it. SimpleTree.root is now computed from the list unless a root is assigned, TreeListWalker.root reads and writes the tree's, as DecoratedTree.root does, and a walker without a focus follows the root. 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.
SimpleTreecomputed itsrootonce, in the constructor. A tree built from an empty list therefore stayed empty after nodes were appended to that list:rootstayedNoneandpositions()yielded nothing.TreeListWalkeralso kept its own copy of the tree's root, and fixed its initial focus to the root at construction, so aTreeBoxopened on an empty tree showed nothing even after the tree was filled and refreshed.SimpleTree.rootis now a property:(0,)while the list has nodes,Nonewhile it is empty. Assigningrootstill works and overrides this (assigningNonerestores the default), asDecoratedTree.root(Read DecoratedTree.root from the wrapped tree #76) forwards assignments to the wrapped tree and its test assigns aSimpleTree's root.TreeListWalker.rootreads the tree's root, and assigning it writes through to the tree, asDecoratedTree.rootdoes since Read DecoratedTree.root from the wrapped tree #76. Before, assigning it changed only the walker's unused copy.Tests:
test_root_follows_list(append to and clear the list) andtest_follows_root_of_tree_filled_later(aTreeBoxon an empty tree, filled and refreshed). Both fail without the fix.Review findings and resolution
review-correctness
TreeListWalker.rootbecame read-only: fixed, it now has a setter that writes through to the tree.SimpleTree.root = Nonecannot force an empty root: left, as an empty root on a non-empty list has no use; the docstring now says that assigningNonerestores the default.TreeBoxmust be refreshed: left,refresh()is the existing contract for any change to the tree.review-design
self.rootinget_focus: fixed.Noneassignment in the description: done above (the walker root is no longer read-only).🤖 Generated with Claude Code