@@ -267,22 +267,6 @@ fn indent_block_with_lines(
267267 let indent_spaces = indent * indent_amount;
268268 if lines. is_empty ( ) {
269269 return ;
270- } else if indent_spaces == 0 {
271- for line in lines {
272- buf. push_str ( prefix) ;
273- // The first indent is special, we only need to print open/close and nothing else
274- if indent == 0 {
275- match style {
276- SpanMode :: Open { .. } => buf. push_str ( LINE_OPEN ) ,
277- SpanMode :: Close { .. } => buf. push_str ( LINE_CLOSE ) ,
278- SpanMode :: PreOpen | SpanMode :: PostClose => { }
279- SpanMode :: Event => { }
280- }
281- }
282- buf. push_str ( line) ;
283- buf. push ( '\n' ) ;
284- }
285- return ;
286270 }
287271 let mut s = String :: with_capacity ( indent_spaces + prefix. len ( ) ) ;
288272 s. push_str ( prefix) ;
@@ -297,7 +281,7 @@ fn indent_block_with_lines(
297281
298282 // instead of using all spaces to indent, draw a vertical line at every indent level
299283 // up until the last indent
300- for i in 0 ..( indent_spaces - indent_amount) {
284+ for i in 0 ..indent_spaces. saturating_sub ( indent_amount) {
301285 indent ( & mut s, i)
302286 }
303287
@@ -328,9 +312,11 @@ fn indent_block_with_lines(
328312 }
329313 }
330314 SpanMode :: Open { verbose : false } => {
331- buf. push_str ( LINE_BRANCH ) ;
332- for _ in 1 ..indent_amount {
333- buf. push_str ( LINE_HORIZ ) ;
315+ if indent_spaces != 0 {
316+ buf. push_str ( LINE_BRANCH ) ;
317+ for _ in 1 ..indent_amount {
318+ buf. push_str ( LINE_HORIZ ) ;
319+ }
334320 }
335321 if lines. len ( ) > 1 {
336322 buf. push_str ( ARGS_BRANCH ) ;
@@ -342,24 +328,29 @@ fn indent_block_with_lines(
342328 buf. push_str ( LINE_HORIZ ) ;
343329 }
344330 buf. push_str ( " " ) ;
345- for i in 0 ..indent_amount {
346- indent ( & mut s, i)
331+
332+ if indent_spaces != 0 {
333+ for i in 0 ..indent_amount {
334+ indent ( & mut s, i)
335+ }
347336 }
348337 } else {
349338 buf. push_str ( LINE_OPEN ) ;
350339 }
351340 }
352341 SpanMode :: Open { verbose : true } => {
353- buf. push_str ( LINE_VERT ) ;
354- for _ in 1 ..( indent_amount / 2 ) {
355- buf. push ( ' ' ) ;
356- }
357- // We don't have the space for fancy rendering at single space indent.
358- if indent_amount > 1 {
359- buf. push ( '└' ) ;
360- }
361- for _ in ( indent_amount / 2 ) ..( indent_amount - 1 ) {
362- buf. push_str ( LINE_HORIZ ) ;
342+ if indent_spaces != 0 {
343+ buf. push_str ( LINE_VERT ) ;
344+ for _ in 1 ..( indent_amount / 2 ) {
345+ buf. push ( ' ' ) ;
346+ }
347+ // We don't have the space for fancy rendering at single space indent.
348+ if indent_amount > 1 {
349+ buf. push ( '└' ) ;
350+ }
351+ for _ in ( indent_amount / 2 ) ..( indent_amount - 1 ) {
352+ buf. push_str ( LINE_HORIZ ) ;
353+ }
363354 }
364355 // We don't have the space for fancy rendering at single space indent.
365356 if indent_amount > 1 {
@@ -373,8 +364,10 @@ fn indent_block_with_lines(
373364 buf. push_str ( LINE_HORIZ ) ;
374365 }
375366 buf. push_str ( " " ) ;
376- for i in 0 ..indent_amount {
377- indent ( & mut s, i)
367+ if indent_spaces != 0 {
368+ for i in 0 ..indent_amount {
369+ indent ( & mut s, i)
370+ }
378371 }
379372 } else {
380373 buf. push_str ( LINE_OPEN ) ;
@@ -384,23 +377,27 @@ fn indent_block_with_lines(
384377 }
385378 }
386379 SpanMode :: Close { verbose : false } => {
387- buf. push_str ( LINE_BRANCH ) ;
388- for _ in 1 ..indent_amount {
389- buf. push_str ( LINE_HORIZ ) ;
380+ if indent_spaces != 0 {
381+ buf. push_str ( LINE_BRANCH ) ;
382+ for _ in 1 ..indent_amount {
383+ buf. push_str ( LINE_HORIZ ) ;
384+ }
390385 }
391386 buf. push_str ( LINE_CLOSE ) ;
392387 }
393388 SpanMode :: Close { verbose : true } => {
394- buf. push_str ( LINE_VERT ) ;
395- for _ in 1 ..( indent_amount / 2 ) {
396- buf. push ( ' ' ) ;
397- }
398- // We don't have the space for fancy rendering at single space indent.
399- if indent_amount > 1 {
400- buf. push ( '┌' ) ;
401- }
402- for _ in ( indent_amount / 2 ) ..( indent_amount - 1 ) {
403- buf. push_str ( LINE_HORIZ ) ;
389+ if indent_spaces != 0 {
390+ buf. push_str ( LINE_VERT ) ;
391+ for _ in 1 ..( indent_amount / 2 ) {
392+ buf. push ( ' ' ) ;
393+ }
394+ // We don't have the space for fancy rendering at single space indent.
395+ if indent_amount > 1 {
396+ buf. push ( '┌' ) ;
397+ }
398+ for _ in ( indent_amount / 2 ) ..( indent_amount - 1 ) {
399+ buf. push_str ( LINE_HORIZ ) ;
400+ }
404401 }
405402 // We don't have the space for fancy rendering at single space indent.
406403 if indent_amount > 1 {
@@ -414,8 +411,11 @@ fn indent_block_with_lines(
414411 buf. push_str ( LINE_HORIZ ) ;
415412 }
416413 buf. push_str ( " " ) ;
417- for i in 0 ..indent_amount - 1 {
418- indent ( & mut s, i)
414+
415+ if indent_spaces != 0 {
416+ for i in 0 ..indent_amount - 1 {
417+ indent ( & mut s, i)
418+ }
419419 }
420420 } else {
421421 buf. push_str ( LINE_CLOSE ) ;
@@ -447,27 +447,40 @@ fn indent_block_with_lines(
447447 }
448448 }
449449 SpanMode :: Event => {
450- buf. push_str ( LINE_BRANCH ) ;
450+ if indent_spaces != 0 {
451+ buf. push_str ( LINE_BRANCH ) ;
452+ }
451453 if lines. len ( ) > 1 {
452- for _ in 0 ..( indent_amount - 1 ) {
453- buf. push_str ( LINE_HORIZ ) ;
454+ if indent_spaces != 0 {
455+ for _ in 0 ..( indent_amount - 1 ) {
456+ buf. push_str ( LINE_HORIZ ) ;
457+ }
454458 }
455459 buf. push_str ( ARGS_BRANCH ) ;
456460 }
457461
458- // add `indent_amount - 1` horizontal lines before the span/event
459- for _ in 0 ..( indent_amount - 1 ) {
460- buf. push_str ( LINE_HORIZ ) ;
462+ if indent_spaces != 0 {
463+ // add `indent_amount - 1` horizontal lines before the span/event
464+ for _ in 0 ..( indent_amount - 1 ) {
465+ buf. push_str ( LINE_HORIZ ) ;
466+ }
461467 }
462468 }
463469 }
464470 buf. push_str ( lines[ 0 ] ) ;
465471 buf. push ( '\n' ) ;
466472
467- // add the rest of the indentation, since we don't want to draw horizontal lines
468- // for subsequent lines
469- for i in 0 ..indent_amount {
470- indent ( & mut s, i)
473+ match style {
474+ SpanMode :: Close { verbose : true } if indent_spaces == 0 => {
475+ s. push ( ' ' ) ;
476+ }
477+ _ => {
478+ // add the rest of the indentation, since we don't want to draw horizontal lines
479+ // for subsequent lines
480+ for i in 0 ..indent_amount {
481+ indent ( & mut s, i)
482+ }
483+ }
471484 }
472485
473486 // add all of the actual content, with each line preceded by the indent string
0 commit comments