Commit
Author: Kevin Schoon [me@kevinschoon.com]
Hash: 045d20e7edc48a64c4747c087c9ec98571b7684f
Timestamp: Fri, 10 Jun 2022 18:52:49 +0000 (2 years ago)

+2 -6 +/-1 browse
simplify tree
1diff --git a/pkg/hierarchy/tree.go b/pkg/hierarchy/tree.go
2index 0c02123..68978f8 100644
3--- a/pkg/hierarchy/tree.go
4+++ b/pkg/hierarchy/tree.go
5 @@ -18,10 +18,6 @@ type Tree struct {
6 Notes []*Note
7 }
8
9- func (t Tree) next(value bool, depth []bool) (result []bool) {
10- return append(append(result, depth...), value)
11- }
12-
13 func (t Tree) fill(w io.Writer, depth []bool) {
14 for i := 0; i < len(depth); i++ {
15 if depth[i] {
16 @@ -46,8 +42,8 @@ func (t Tree) write(notes []*Note, depth []bool, buf *bytes.Buffer) {
17 buf.WriteString(np.Name() + "\n")
18 }
19 if len(note.Descendants) > 0 {
20- t.write(note.Descendants, t.next(len(note.Descendants) >
21- 0 && !last, depth), buf)
22+ t.write(note.Descendants,
23+ append(depth, len(note.Descendants) > 0 && !last), buf)
24 }
25 }
26 }