MCPcopy
hub / github.com/wagoodman/dive / renderTreeLine

Method renderTreeLine

dive/filetree/file_node.go:54–75  ·  view source on GitHub ↗

renderTreeLine returns a string representing this FileNode in the context of a greater ASCII tree.

(spaces []bool, last bool, collapsed bool)

Source from the content-addressed store, hash-verified

52
53// renderTreeLine returns a string representing this FileNode in the context of a greater ASCII tree.
54func (node *FileNode) renderTreeLine(spaces []bool, last bool, collapsed bool) string {
55 var otherBranches string
56 for _, space := range spaces {
57 if space {
58 otherBranches += noBranchSpace
59 } else {
60 otherBranches += branchSpace
61 }
62 }
63
64 thisBranch := middleItem
65 if last {
66 thisBranch = lastItem
67 }
68
69 collapsedIndicator := uncollapsedItem
70 if collapsed {
71 collapsedIndicator = collapsedItem
72 }
73
74 return otherBranches + thisBranch + collapsedIndicator + node.String() + newLine
75}
76
77// Copy duplicates the existing node relative to a new parent node.
78func (node *FileNode) Copy(parent *FileNode) *FileNode {

Callers 1

Calls 1

StringMethod · 0.95

Tested by

no test coverage detected