@@ -218,12 +218,17 @@ impl<'a> DisplayList<'a> {
218
218
} else {
219
219
false
220
220
} ;
221
+ // Specifies that it will end on the next character, so it will return
222
+ // until the next one to the final condition.
221
223
let mut ended = false ;
222
224
let range = text
223
225
. char_indices ( )
224
- . chain ( once ( ( text. len ( ) , '0円' ) ) )
225
226
. skip ( left)
227
+ // Complete char iterator with final character
228
+ . chain ( once ( ( text. len ( ) , '0円' ) ) )
229
+ // Take until the next one to the final condition
226
230
. take_while ( |( _, ch) | {
231
+ // Fast return to iterate over final byte position
227
232
if ended {
228
233
return false ;
229
234
}
@@ -236,6 +241,7 @@ impl<'a> DisplayList<'a> {
236
241
}
237
242
true
238
243
} )
244
+ // Reduce to start and end byte position
239
245
. fold ( ( None , 0 ) , |acc, ( i, _) | {
240
246
if acc. 0 . is_some ( ) {
241
247
( acc. 0 , i)
@@ -244,6 +250,7 @@ impl<'a> DisplayList<'a> {
244
250
}
245
251
} ) ;
246
252
253
+ // Format text with margins
247
254
text[ range. 0 . expect ( "One character at line" ) ..range. 1 ] . fmt ( f) ?;
248
255
249
256
if cut_right {
0 commit comments