@@ -131,7 +131,18 @@ export function formatQuotaRowsGrouped(params: {
131131 : [ groupHeader . slice ( 0 , maxWidth ) ] ) ,
132132 ) ;
133133
134+ let renderedEntryBlocks = 0 ;
134135 for ( const entry of list ) {
136+ let entryBlockStarted = false ;
137+ const pushEntryLine = ( line : string ) => {
138+ if ( ! entryBlockStarted ) {
139+ if ( renderedEntryBlocks > 0 ) lines . push ( "" ) ;
140+ renderedEntryBlocks ++ ;
141+ entryBlockStarted = true ;
142+ }
143+ lines . push ( line ) ;
144+ } ;
145+
135146 const interpretation = interpretAccountingRow ( entry , {
136147 booleanWording : "semantic" ,
137148 ...( ! isTiny
@@ -170,24 +181,24 @@ export function formatQuotaRowsGrouped(params: {
170181 labelAndValue . length <= maxWidth &&
171182 labelAndValue . length + separator . length + timeStr . length > maxWidth
172183 ) {
173- lines . push ( labelAndValue ) ;
174- lines . push ( padLeft ( timeStr , maxWidth ) ) ;
184+ pushEntryLine ( labelAndValue ) ;
185+ pushEntryLine ( padLeft ( timeStr , maxWidth ) ) ;
175186 continue ;
176187 }
177188
178189 if ( isAtomicValue ) {
179190 const suffix = [ value , timeStr ] . filter ( Boolean ) . join ( separator ) ;
180191 if ( suffix . length > maxWidth ) {
181- if ( value . length <= maxWidth ) lines . push ( padLeft ( value , maxWidth ) ) ;
192+ if ( value . length <= maxWidth ) pushEntryLine ( padLeft ( value , maxWidth ) ) ;
182193 continue ;
183194 }
184195 const availableLabelWidth = maxWidth - ( suffix ? separator . length + suffix . length : 0 ) ;
185196 if ( availableLabelWidth <= 0 ) {
186- lines . push ( padLeft ( suffix , maxWidth ) ) ;
197+ pushEntryLine ( padLeft ( suffix , maxWidth ) ) ;
187198 continue ;
188199 }
189200 const leftText = label . slice ( 0 , availableLabelWidth ) . trimEnd ( ) ;
190- lines . push (
201+ pushEntryLine (
191202 `${ padRight ( leftText , availableLabelWidth ) } ${ suffix ? `${ separator } ${ suffix } ` : "" } ` ,
192203 ) ;
193204 continue ;
@@ -207,7 +218,7 @@ export function formatQuotaRowsGrouped(params: {
207218 padLeft ( timeStr , timeWidth ) ,
208219 padLeft ( value , valueCol ) ,
209220 ] . join ( separator ) ;
210- lines . push ( line . slice ( 0 , maxWidth ) ) ;
221+ pushEntryLine ( line . slice ( 0 , maxWidth ) ) ;
211222 continue ;
212223 }
213224
@@ -218,7 +229,7 @@ export function formatQuotaRowsGrouped(params: {
218229 1 ,
219230 barWidth - separator . length - valueWidth - separator . length - timeWidth ,
220231 ) ;
221- lines . push (
232+ pushEntryLine (
222233 (
223234 padRight ( leftText , leftMax ) +
224235 separator +
@@ -260,7 +271,7 @@ export function formatQuotaRowsGrouped(params: {
260271 : "" ;
261272 const runway = isPercentEntry ( entry ) ? formatQuotaRunway ( entry . runway ) : "" ;
262273 const addRunwayLine = ( ) => {
263- if ( runway ) lines . push ( `Runs out ${ runway } ` . slice ( 0 , maxWidth ) ) ;
274+ if ( runway ) pushEntryLine ( `Runs out ${ runway } ` . slice ( 0 , maxWidth ) ) ;
264275 } ;
265276
266277 if ( isTiny ) {
@@ -277,7 +288,7 @@ export function formatQuotaRowsGrouped(params: {
277288 padLeft ( timeStr , timeWidth ) ,
278289 padLeft ( visibleBarSuffix , percentValueCol ) ,
279290 ] . join ( separator ) ;
280- lines . push ( line . slice ( 0 , maxWidth ) ) ;
291+ pushEntryLine ( line . slice ( 0 , maxWidth ) ) ;
281292 addRunwayLine ( ) ;
282293 continue ;
283294 }
@@ -290,7 +301,7 @@ export function formatQuotaRowsGrouped(params: {
290301 padLeft ( timeStr , timeWidth ) ,
291302 padLeft ( visibleBarSuffix , percentValueCol ) ,
292303 ] . join ( separator ) ;
293- lines . push ( line . slice ( 0 , maxWidth ) ) ;
304+ pushEntryLine ( line . slice ( 0 , maxWidth ) ) ;
294305 addRunwayLine ( ) ;
295306 continue ;
296307 }
@@ -305,23 +316,23 @@ export function formatQuotaRowsGrouped(params: {
305316 const rightText = parts . slice ( 1 ) . join ( " " ) ;
306317 const sep = " " ;
307318 const leftWidth = Math . max ( 1 , maxWidth - sep . length - rightText . length ) ;
308- lines . push ( ( padRight ( left , leftWidth ) + sep + rightText ) . slice ( 0 , maxWidth ) ) ;
319+ pushEntryLine ( ( padRight ( left , leftWidth ) + sep + rightText ) . slice ( 0 , maxWidth ) ) ;
309320 } else {
310- lines . push ( padLeft ( text , maxWidth ) ) ;
321+ pushEntryLine ( padLeft ( text , maxWidth ) ) ;
311322 }
312323 } else {
313324 // Line 1: label + time at end
314325 const timeWidth = Math . max ( timeStr . length , timeCol ) ;
315326 const leftMax = Math . max ( 1 , maxWidth - separator . length - timeWidth ) ;
316- lines . push (
327+ pushEntryLine (
317328 ( padRight ( label , leftMax ) + separator + padLeft ( timeStr , timeWidth ) ) . slice ( 0 , maxWidth ) ,
318329 ) ;
319330 }
320331
321332 // Line 2: bar + percent
322333 const barCell = bar ( displayedPercent , barWidth ) ;
323334 const suffixCell = padLeft ( percentLabel . slice ( 0 , percentValueCol ) , percentValueCol ) ;
324- lines . push ( [ barCell , suffixCell ] . join ( separator ) ) ;
335+ pushEntryLine ( [ barCell , suffixCell ] . join ( separator ) ) ;
325336 addRunwayLine ( ) ;
326337
327338 if ( interpretation . basis ) {
@@ -337,7 +348,7 @@ export function formatQuotaRowsGrouped(params: {
337348 if ( next . length > maxWidth ) break ;
338349 detailLine = next ;
339350 }
340- if ( detailLine ) lines . push ( detailLine ) ;
351+ if ( detailLine ) pushEntryLine ( detailLine ) ;
341352 }
342353 }
343354 }
0 commit comments