@@ -480,7 +480,13 @@ impl HelpTemplate<'_, '_> {
480480 should_show_arg ( self . use_long , arg)
481481 } ) {
482482 if longest_filter ( arg) {
483- longest = longest. max ( display_width ( & arg. to_string ( ) ) ) ;
483+ let width = display_width ( & arg. to_string ( ) ) ;
484+ let actual_width = if arg. is_positional ( ) {
485+ width
486+ } else {
487+ width + SHORT_SIZE
488+ } ;
489+ longest = longest. max ( actual_width) ;
484490 debug ! (
485491 "HelpTemplate::write_args: arg={:?} longest={}" ,
486492 arg. get_id( ) ,
@@ -569,7 +575,7 @@ impl HelpTemplate<'_, '_> {
569575 debug ! ( "HelpTemplate::align_to_about: printing long help so skip alignment" ) ;
570576 0
571577 } else if !arg. is_positional ( ) {
572- let self_len = display_width ( & arg. to_string ( ) ) ;
578+ let self_len = display_width ( & arg. to_string ( ) ) + SHORT_SIZE ;
573579 // Since we're writing spaces from the tab point we first need to know if we
574580 // had a long and short, or just short
575581 let padding = if arg. get_long ( ) . is_some ( ) {
@@ -622,10 +628,8 @@ impl HelpTemplate<'_, '_> {
622628
623629 let spaces = if next_line_help {
624630 TAB . len ( ) + NEXT_LINE_INDENT . len ( )
625- } else if arg. map ( |a| a. is_positional ( ) ) . unwrap_or ( true ) {
626- longest + TAB_WIDTH * 2
627631 } else {
628- longest + TAB_WIDTH * 2 + SHORT_SIZE
632+ longest + TAB_WIDTH * 2
629633 } ;
630634 let trailing_indent = spaces; // Don't indent any further than the first line is indented
631635 let trailing_indent = self . get_spaces ( trailing_indent) ;
@@ -726,11 +730,7 @@ impl HelpTemplate<'_, '_> {
726730 . or_else ( || arg. get_long_help ( ) )
727731 . unwrap_or_default ( ) ;
728732 let h_w = h. display_width ( ) + display_width ( spec_vals) ;
729- let taken = if arg. is_positional ( ) {
730- longest + TAB_WIDTH * 2
731- } else {
732- longest + TAB_WIDTH * 2 + SHORT_SIZE
733- } ;
733+ let taken = longest + TAB_WIDTH * 2 ;
734734 self . term_w >= taken
735735 && ( taken as f32 / self . term_w as f32 ) > 0.40
736736 && h_w > ( self . term_w - taken)
0 commit comments