From 67e51c9f1bd1105b0c5c1059ce9e301b7ca26973 Mon Sep 17 00:00:00 2001 From: Blallo Date: Mon, 2 Mar 2020 11:27:02 +0100 Subject: [PATCH] Avoid duplication at the tip of the tree. --- dynamic_tree.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/dynamic_tree.go b/dynamic_tree.go index aea8db6..af23a6a 100644 --- a/dynamic_tree.go +++ b/dynamic_tree.go @@ -257,12 +257,14 @@ func (i *Intermediate) String() string { childLines := strings.Split(lines[treeSize-1], "\n") lenChildLines := len(childLines) - out += fmt.Sprintf("%s%s%s\n", NodePad, NodeL, childLines[0]) - for a := 1; a < lenChildLines-2; a++ { - out += fmt.Sprintf("%s%s%s\n", NodePad, NodePad, childLines[a]) - } - if lenChildLines > 0 { + if lenChildLines > 1 { + out += fmt.Sprintf("%s%s%s\n", NodePad, NodeL, childLines[0]) + for a := 1; a < lenChildLines-2; a++ { + out += fmt.Sprintf("%s%s%s\n", NodePad, NodePad, childLines[a]) + } out += fmt.Sprintf("%s%s%s", NodePad, NodePad, childLines[lenChildLines-1]) + } else { + out += fmt.Sprintf("%s%s%s", NodePad, NodeL, childLines[0]) } return out }