File tree Expand file tree Collapse file tree 2 files changed +38
-15
lines changed Expand file tree Collapse file tree 2 files changed +38
-15
lines changed Original file line number Diff line number Diff line change @@ -257,7 +257,10 @@ func (n Node) AddLine(text string) {
257257 text = " " + text
258258 }
259259 rowIdx := t .addRow (n .level - 1 , text )
260- if t .style != BulletStyle {
260+ // We have to start the line for the first child later, unless we are using
261+ // the bullet style or the text starts with spaces.
262+ if (t .style == CompactStyle && ! strings .HasPrefix (text , " " )) ||
263+ (t .style == DefaultStyle && ! strings .HasPrefix (text , " " )) {
261264 t .stack [n .level - 1 ].firstChildConnectRow = rowIdx
262265 }
263266}
Original file line number Diff line number Diff line change @@ -25,9 +25,12 @@ func TestTreePrinter(t *testing.T) {
2525 n13 .AddEmptyLine ()
2626 n131 := n13 .Child ("1.3.1" )
2727 n131 .AddLine ("1.3.1a" )
28- n13 .Child ("1.3.2\n 1.3.2a" )
28+ n132 := n13 .Child ("1.3.2\n 1.3.2a" )
2929 n13 .AddEmptyLine ()
30- n131 .Child ("1.3.1.1\n 1.3.1.1a" )
30+ n132 .Child ("1.3.2.1\n 1.3.2.1a" )
31+ n133 := n13 .Child ("1.3.3\n some info\n more info" )
32+ n133 .AddEmptyLine ()
33+ n133 .Child ("1.3.3.1" )
3134 n1 .Child ("1.4" )
3235 r .Child ("2" )
3336 }
5154 │ │ │
5255 │ │ ├── 1.3.1
5356 │ │ │ 1.3.1a
54- │ │ └── 1.3.2
55- │ │ 1.3.2a
57+ │ │ ├── 1.3.2
58+ │ │ │ 1.3.2a
59+ │ │ │ │
60+ │ │ │ └── 1.3.2.1
61+ │ │ │ 1.3.2.1a
62+ │ │ └── 1.3.3
63+ │ │ │ some info
64+ │ │ │ more info
5665 │ │ │
57- │ │ └── 1.3.1.1
58- │ │ 1.3.1.1a
66+ │ │ └── 1.3.3.1
5967 │ └── 1.4
6068 └── 2
6169`
8290│ │ │
8391│ │ ├ 1.3.1
8492│ │ │ 1.3.1a
85- │ │ └ 1.3.2
86- │ │ 1.3.2a
93+ │ │ ├ 1.3.2
94+ │ │ │ 1.3.2a
95+ │ │ │ │
96+ │ │ │ └ 1.3.2.1
97+ │ │ │ 1.3.2.1a
98+ │ │ └ 1.3.3
99+ │ │ │ some info
100+ │ │ │ more info
87101│ │ │
88- │ │ └ 1.3.1.1
89- │ │ 1.3.1.1a
102+ │ │ └ 1.3.3.1
90103│ └ 1.4
91104└ 2
92105`
@@ -121,12 +134,19 @@ root
121134│ │ ├── • 1.3.1
122135│ │ │ 1.3.1a
123136│ │ │
124- │ │ └── • 1.3.2
125- │ │ │ 1.3.2a
137+ │ │ ├── • 1.3.2
138+ │ │ │ │ 1.3.2a
139+ │ │ │ │
140+ │ │ │ │
141+ │ │ │ └── • 1.3.2.1
142+ │ │ │ 1.3.2.1a
143+ │ │ │
144+ │ │ └── • 1.3.3
145+ │ │ │ some info
146+ │ │ │ more info
126147│ │ │
127148│ │ │
128- │ │ └── • 1.3.1.1
129- │ │ 1.3.1.1a
149+ │ │ └── • 1.3.3.1
130150│ │
131151│ └── • 1.4
132152│
You can’t perform that action at this time.
0 commit comments