@@ -94,26 +94,19 @@ function compactSection(cmd: Command, helper: Help): string {
9494 // Leave room for the value column; never wrap narrower than 20 cols.
9595 const wrapWidth = Math . max ( 20 , termWidth - valueCol ) ;
9696
97- // Render each group to its own block of lines (a label line plus any wrapped
98- // continuation lines).
99- const blocks = rows . map ( ( row ) => {
97+ const lines : string [ ] = [ ] ;
98+ for ( const row of rows ) {
10099 const label = INDENT + row . name . padEnd ( nameWidth + 2 ) ;
101100 if ( row . children . length === 0 ) {
102- return [ label . trimEnd ( ) ] ;
101+ lines . push ( label . trimEnd ( ) ) ;
102+ continue ;
103103 }
104104 const wrapped = wrapTokens ( row . children , wrapWidth ) ;
105- return [ label + wrapped [ 0 ] , ...wrapped . slice ( 1 ) . map ( ( w ) => ' ' . repeat ( valueCol ) + w ) ] ;
106- } ) ;
107-
108- // Separate every group with a blank line so each reads as one unit and the
109- // wrapped groups' continuation lines never look like separate entries.
110- const lines : string [ ] = [ ] ;
111- blocks . forEach ( ( block , i ) => {
112- if ( i > 0 ) {
113- lines . push ( '' ) ;
105+ lines . push ( label + wrapped [ 0 ] ) ;
106+ for ( let i = 1 ; i < wrapped . length ; i ++ ) {
107+ lines . push ( ' ' . repeat ( valueCol ) + wrapped [ i ] ) ;
114108 }
115- lines . push ( ...block ) ;
116- } ) ;
109+ }
117110
118111 return `\nCommand groups (nested):\n${ lines . join ( '\n' ) } \n` ;
119112}
0 commit comments