@@ -266,22 +266,6 @@ fn indent_block_with_lines(
266266 let indent_spaces = indent * indent_amount;
267267 if lines. is_empty ( ) {
268268 return ;
269- } else if indent_spaces == 0 {
270- for line in lines {
271- buf. push_str ( prefix) ;
272- // The first indent is special, we only need to print open/close and nothing else
273- if indent == 0 {
274- match style {
275- SpanMode :: Open { .. } => buf. push_str ( LINE_OPEN ) ,
276- SpanMode :: Close { .. } => buf. push_str ( LINE_CLOSE ) ,
277- SpanMode :: PreOpen | SpanMode :: PostClose => { }
278- SpanMode :: Event => { }
279- }
280- }
281- buf. push_str ( line) ;
282- buf. push ( '\n' ) ;
283- }
284- return ;
285269 }
286270 let mut s = String :: with_capacity ( indent_spaces + prefix. len ( ) ) ;
287271 s. push_str ( prefix) ;
@@ -296,7 +280,7 @@ fn indent_block_with_lines(
296280
297281 // instead of using all spaces to indent, draw a vertical line at every indent level
298282 // up until the last indent
299- for i in 0 ..( indent_spaces - indent_amount) {
283+ for i in 0 ..indent_spaces. saturating_sub ( indent_amount) {
300284 indent ( & mut s, i)
301285 }
302286
@@ -327,9 +311,11 @@ fn indent_block_with_lines(
327311 }
328312 }
329313 SpanMode :: Open { verbose : false } => {
330- buf. push_str ( LINE_BRANCH ) ;
331- for _ in 1 ..indent_amount {
332- buf. push_str ( LINE_HORIZ ) ;
314+ if indent_spaces != 0 {
315+ buf. push_str ( LINE_BRANCH ) ;
316+ for _ in 1 ..indent_amount {
317+ buf. push_str ( LINE_HORIZ ) ;
318+ }
333319 }
334320 if lines. len ( ) > 1 {
335321 buf. push_str ( ARGS_BRANCH ) ;
@@ -341,24 +327,29 @@ fn indent_block_with_lines(
341327 buf. push_str ( LINE_HORIZ ) ;
342328 }
343329 buf. push_str ( " " ) ;
344- for i in 0 ..indent_amount {
345- indent ( & mut s, i)
330+
331+ if indent_spaces != 0 {
332+ for i in 0 ..indent_amount {
333+ indent ( & mut s, i)
334+ }
346335 }
347336 } else {
348337 buf. push_str ( LINE_OPEN ) ;
349338 }
350339 }
351340 SpanMode :: Open { verbose : true } => {
352- buf. push_str ( LINE_VERT ) ;
353- for _ in 1 ..( indent_amount / 2 ) {
354- buf. push ( ' ' ) ;
355- }
356- // We don't have the space for fancy rendering at single space indent.
357- if indent_amount > 1 {
358- buf. push ( '└' ) ;
359- }
360- for _ in ( indent_amount / 2 ) ..( indent_amount - 1 ) {
361- buf. push_str ( LINE_HORIZ ) ;
341+ if indent_spaces != 0 {
342+ buf. push_str ( LINE_VERT ) ;
343+ for _ in 1 ..( indent_amount / 2 ) {
344+ buf. push ( ' ' ) ;
345+ }
346+ // We don't have the space for fancy rendering at single space indent.
347+ if indent_amount > 1 {
348+ buf. push ( '└' ) ;
349+ }
350+ for _ in ( indent_amount / 2 ) ..( indent_amount - 1 ) {
351+ buf. push_str ( LINE_HORIZ ) ;
352+ }
362353 }
363354 // We don't have the space for fancy rendering at single space indent.
364355 if indent_amount > 1 {
@@ -372,8 +363,10 @@ fn indent_block_with_lines(
372363 buf. push_str ( LINE_HORIZ ) ;
373364 }
374365 buf. push_str ( " " ) ;
375- for i in 0 ..indent_amount {
376- indent ( & mut s, i)
366+ if indent_spaces != 0 {
367+ for i in 0 ..indent_amount {
368+ indent ( & mut s, i)
369+ }
377370 }
378371 } else {
379372 buf. push_str ( LINE_OPEN ) ;
@@ -383,23 +376,27 @@ fn indent_block_with_lines(
383376 }
384377 }
385378 SpanMode :: Close { verbose : false } => {
386- buf. push_str ( LINE_BRANCH ) ;
387- for _ in 1 ..indent_amount {
388- buf. push_str ( LINE_HORIZ ) ;
379+ if indent_spaces != 0 {
380+ buf. push_str ( LINE_BRANCH ) ;
381+ for _ in 1 ..indent_amount {
382+ buf. push_str ( LINE_HORIZ ) ;
383+ }
389384 }
390385 buf. push_str ( LINE_CLOSE ) ;
391386 }
392387 SpanMode :: Close { verbose : true } => {
393- buf. push_str ( LINE_VERT ) ;
394- for _ in 1 ..( indent_amount / 2 ) {
395- buf. push ( ' ' ) ;
396- }
397- // We don't have the space for fancy rendering at single space indent.
398- if indent_amount > 1 {
399- buf. push ( '┌' ) ;
400- }
401- for _ in ( indent_amount / 2 ) ..( indent_amount - 1 ) {
402- buf. push_str ( LINE_HORIZ ) ;
388+ if indent_spaces != 0 {
389+ buf. push_str ( LINE_VERT ) ;
390+ for _ in 1 ..( indent_amount / 2 ) {
391+ buf. push ( ' ' ) ;
392+ }
393+ // We don't have the space for fancy rendering at single space indent.
394+ if indent_amount > 1 {
395+ buf. push ( '┌' ) ;
396+ }
397+ for _ in ( indent_amount / 2 ) ..( indent_amount - 1 ) {
398+ buf. push_str ( LINE_HORIZ ) ;
399+ }
403400 }
404401 // We don't have the space for fancy rendering at single space indent.
405402 if indent_amount > 1 {
@@ -413,8 +410,11 @@ fn indent_block_with_lines(
413410 buf. push_str ( LINE_HORIZ ) ;
414411 }
415412 buf. push_str ( " " ) ;
416- for i in 0 ..indent_amount - 1 {
417- indent ( & mut s, i)
413+
414+ if indent_spaces != 0 {
415+ for i in 0 ..indent_amount - 1 {
416+ indent ( & mut s, i)
417+ }
418418 }
419419 } else {
420420 buf. push_str ( LINE_CLOSE ) ;
@@ -446,27 +446,40 @@ fn indent_block_with_lines(
446446 }
447447 }
448448 SpanMode :: Event => {
449- buf. push_str ( LINE_BRANCH ) ;
449+ if indent_spaces != 0 {
450+ buf. push_str ( LINE_BRANCH ) ;
451+ }
450452 if lines. len ( ) > 1 {
451- for _ in 0 ..( indent_amount - 1 ) {
452- buf. push_str ( LINE_HORIZ ) ;
453+ if indent_spaces != 0 {
454+ for _ in 0 ..( indent_amount - 1 ) {
455+ buf. push_str ( LINE_HORIZ ) ;
456+ }
453457 }
454458 buf. push_str ( ARGS_BRANCH ) ;
455459 }
456460
457- // add `indent_amount - 1` horizontal lines before the span/event
458- for _ in 0 ..( indent_amount - 1 ) {
459- buf. push_str ( LINE_HORIZ ) ;
461+ if indent_spaces != 0 {
462+ // add `indent_amount - 1` horizontal lines before the span/event
463+ for _ in 0 ..( indent_amount - 1 ) {
464+ buf. push_str ( LINE_HORIZ ) ;
465+ }
460466 }
461467 }
462468 }
463469 buf. push_str ( lines[ 0 ] ) ;
464470 buf. push ( '\n' ) ;
465471
466- // add the rest of the indentation, since we don't want to draw horizontal lines
467- // for subsequent lines
468- for i in 0 ..indent_amount {
469- indent ( & mut s, i)
472+ match style {
473+ SpanMode :: Close { verbose : true } if indent_spaces == 0 => {
474+ s. push ( ' ' ) ;
475+ }
476+ _ => {
477+ // add the rest of the indentation, since we don't want to draw horizontal lines
478+ // for subsequent lines
479+ for i in 0 ..indent_amount {
480+ indent ( & mut s, i)
481+ }
482+ }
470483 }
471484
472485 // add all of the actual content, with each line preceded by the indent string
0 commit comments