File tree Expand file tree Collapse file tree 4 files changed +60
-0
lines changed Expand file tree Collapse file tree 4 files changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,10 @@ func (l *List) UnIndent() {
120
120
}
121
121
}
122
122
123
+ func (l * List ) UnIndentAll () {
124
+ l .level = 0
125
+ }
126
+
123
127
func (l * List ) initForRender () {
124
128
// pick a default style
125
129
l .Style ()
Original file line number Diff line number Diff line change @@ -149,3 +149,14 @@ func TestList_UnIndent(t *testing.T) {
149
149
list .UnIndent ()
150
150
assert .Equal (t , 0 , list .level )
151
151
}
152
+
153
+ func TestList_UnIndentAll (t * testing.T ) {
154
+ list := List {level : 3 }
155
+
156
+ list .UnIndentAll ()
157
+ assert .Equal (t , 0 , list .level )
158
+
159
+ // Ensure level is still 0 after 2 consecutive calls
160
+ list .UnIndentAll ()
161
+ assert .Equal (t , 0 , list .level )
162
+ }
Original file line number Diff line number Diff line change @@ -289,3 +289,47 @@ func TestList_Render_Styles(t *testing.T) {
289
289
fmt .Println (mismatch )
290
290
}
291
291
}
292
+
293
+ func TestList_Render_UnindentAll (t * testing.T ) {
294
+ lw := NewWriter ()
295
+ lw .AppendItem (testItem1 )
296
+ lw .Indent ()
297
+ lw .AppendItems (testItems2 )
298
+ lw .Indent ()
299
+ lw .AppendItems (testItems3 )
300
+ lw .UnIndentAll ()
301
+ lw .AppendItem (testItem4 )
302
+ lw .Indent ()
303
+ lw .AppendItem (testItem5 )
304
+ lw .UnIndentAll ()
305
+ lw .AppendItem ("The Mandalorian" )
306
+ lw .Indent ()
307
+ lw .AppendItem ("This" )
308
+ lw .Indent ()
309
+ lw .AppendItem ("Is" )
310
+ lw .Indent ()
311
+ lw .AppendItem ("The" )
312
+ lw .Indent ()
313
+ lw .AppendItem ("Way" )
314
+ lw .Indent ()
315
+ lw .UnIndentAll ()
316
+ lw .AppendItem ("Right?" )
317
+
318
+ expectedOut := `* Game Of Thrones
319
+ * Winter
320
+ * Is
321
+ * Coming
322
+ * This
323
+ * Is
324
+ * Known
325
+ * The Dark Tower
326
+ * The Gunslinger
327
+ * The Mandalorian
328
+ * This
329
+ * Is
330
+ * The
331
+ * Way
332
+ * Right?`
333
+ assert .Equal (t , expectedOut , lw .Render ())
334
+
335
+ }
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ type Writer interface {
17
17
SetStyle (style Style )
18
18
Style () * Style
19
19
UnIndent ()
20
+ UnIndentAll ()
20
21
}
21
22
22
23
// NewWriter initializes and returns a Writer.
You can’t perform that action at this time.
0 commit comments