Skip to content

Commit 0c1c5d6

Browse files
Added numer order to tree display
1 parent 4cd7fd7 commit 0c1c5d6

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/outliner/display.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def tree(self):
3636
connect_branch = (
3737
lines
3838
+ self.ansi_for_tree["CHILD_OBJECT_ANSI"]
39+
+ f"{position}. "
3940
+ i
4041
+ "\n"
4142
+ self.ansi_for_tree["RESET"]
@@ -44,7 +45,11 @@ def tree(self):
4445
connector_display = connector_root if position == 0 else connect_branch
4546

4647
sys.stdout.write(connector_display)
47-
sys.stdout.write(str(" " + self.ansi_for_tree["VERTICAL_LINE"] + "\n"))
48+
49+
if position == (len(self.functions_flow) - 1):
50+
return
51+
52+
sys.stdout.write(str(" " + self.ansi_for_tree["VERTICAL_LINE"]))
4853
sys.stdout.flush()
4954
position += 1
5055

tests/test_display.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def setUp(self):
2828

2929
@patch("sys.stdout", new_callable=StringIO)
3030
def test_display_tree_positive_input(self, stdout):
31-
expected_result = " \x1b[38;5;208mtest2\x1b[0m\n\n\n │──\x1b[36m__init__\n\x1b[0m │\n\n │──\x1b[36mfunc1\n\x1b[0m │\n\n │──\x1b[36mfunc2\n\x1b[0m\n"
31+
expected_result = " \x1b[38;5;208mtest2\x1b[0m\n\n │──\x1b[36m1. __init__\n\x1b[0m │\n │──\x1b[36m2. func1\n\x1b[0m │\n │──\x1b[36m3. func2\n\x1b[0m"
3232
self.parser.tree()
3333
self.assertEqual(stdout.getvalue(), expected_result)
3434

0 commit comments

Comments
 (0)