Skip to content

Commit 8506bfd

Browse files
committed
tree: Start expanded with Textual 0.73+
A backwards-incompatible change released in Textual 0.73 causes the `memray tree` reporter to start with no nodes expanded. Work around this to preserve the old behavior of expanding the first child of each node. Signed-off-by: Matt Wozniski <[email protected]>
1 parent 3b15301 commit 8506bfd

File tree

5 files changed

+1508
-1503
lines changed

5 files changed

+1508
-1503
lines changed

news/648.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
A backwards-incompatible change released in Textual 0.73 caused the ``memray tree`` reporter to start with no nodes expanded. This release adds a workaround to restore the old behavior of expanding the first child of each node.

src/memray/reporters/tree.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,9 @@ def repopulate_tree(self, tree: FrameTree) -> None:
277277
self.add_children(tree.root, self.data.children.values())
278278
self.add_elided_locations_node(tree.root)
279279
tree.root.expand()
280-
tree.select_node(tree.root)
280+
# From Textual 0.73 on, Tree.select_node toggles the node's expanded
281+
# state. The new Tree.move_cursor method selects without expanding.
282+
getattr(tree, "move_cursor", tree.select_node)(tree.root)
281283
self.expand_first_child(tree.root)
282284

283285
def action_expand_linear_group(self) -> None:

0 commit comments

Comments
 (0)