@@ -363,21 +363,29 @@ def best_len(values):
363
363
# adjust all values to max length if needed
364
364
if is_justify :
365
365
if line_break_each_value :
366
+ # Justify each string in the values of head and tail, so the
367
+ # strings will right align when head and tail are stacked
368
+ # vertically.
366
369
head , tail = _justify (head , tail )
367
370
elif (is_truncated or not (len (', ' .join (head )) < display_width and
368
371
len (', ' .join (tail )) < display_width )):
372
+ # Each string in head and tail should align with each other
369
373
max_length = max (best_len (head ), best_len (tail ))
370
374
head = [x .rjust (max_length ) for x in head ]
371
375
tail = [x .rjust (max_length ) for x in tail ]
372
376
# If we are not truncated and we are only a single
373
377
# line, then don't justify
374
378
375
379
if line_break_each_value :
376
- # truncate vertically if wider than max_space
380
+ # Now head and tail are of type List[Tuple[str]]. Below we
381
+ # convert them into List[str], so there will be one string per
382
+ # value. Also truncate items horizontally if wider than
383
+ # max_space
377
384
max_space = display_width - len (space2 )
378
- item = tail [0 ]
379
- for max_items in reversed (range (1 , len (item ) + 1 )):
380
- if len (_pprint_seq (item , max_seq_items = max_items )) < max_space :
385
+ value = tail [0 ]
386
+ for max_items in reversed (range (1 , len (value ) + 1 )):
387
+ pprinted_seq = _pprint_seq (value , max_seq_items = max_items )
388
+ if len (pprinted_seq ) < max_space :
381
389
break
382
390
head = [_pprint_seq (x , max_seq_items = max_items ) for x in head ]
383
391
tail = [_pprint_seq (x , max_seq_items = max_items ) for x in tail ]
0 commit comments