lib: When displaying amounts on a single line, always display at least one amount, even if that would exceed the requested maximum width. Addresses #1526.
This commit is contained in:
		
							parent
							
								
									f5121129ec
								
							
						
					
					
						commit
						28fd7c65f2
					
				| @ -451,7 +451,9 @@ showAmountB opts a@Amount{astyle=style} = | |||||||
| -- | -- | ||||||
| -- If a maximum width is given then: | -- If a maximum width is given then: | ||||||
| -- - If displayed on one line, it will display as many Amounts as can | -- - If displayed on one line, it will display as many Amounts as can | ||||||
| --   fit in the given width, and further Amounts will be elided. | --   fit in the given width, and further Amounts will be elided. There | ||||||
|  | --   will always be at least one amount displayed, even if this will | ||||||
|  | --   exceed the requested maximum width. | ||||||
| -- - If displayed on multiple lines, any Amounts longer than the | -- - If displayed on multiple lines, any Amounts longer than the | ||||||
| --   maximum width will be elided. | --   maximum width will be elided. | ||||||
| showAmountsB :: AmountDisplayOpts -> [Amount] -> WideBuilder | showAmountsB :: AmountDisplayOpts -> [Amount] -> WideBuilder | ||||||
| @ -507,8 +509,10 @@ showAmountsOneLineB opts@AmountDisplayOpts{displayMaxWidth=mmax,displayMinWidth= | |||||||
|     addElide [] = [] |     addElide [] = [] | ||||||
|     addElide xs = maybeAppend (snd $ last xs) $ map fst xs |     addElide xs = maybeAppend (snd $ last xs) $ map fst xs | ||||||
|     -- Return the elements of the display list which fit within the maximum width |     -- Return the elements of the display list which fit within the maximum width | ||||||
|     -- (including their elision strings) |     -- (including their elision strings). Always display at least one amount, | ||||||
|     takeFitting m = dropWhileRev (\(a,e) -> m < adTotal (fromMaybe a e)) |     -- regardless of width. | ||||||
|  |     takeFitting _ []     = [] | ||||||
|  |     takeFitting m (x:xs) = x : dropWhileRev (\(a,e) -> m < adTotal (fromMaybe a e)) xs | ||||||
|     dropWhileRev p = foldr (\x xs -> if null xs && p x then [] else x:xs) [] |     dropWhileRev p = foldr (\x xs -> if null xs && p x then [] else x:xs) [] | ||||||
| 
 | 
 | ||||||
|     -- Add the elision strings (if any) to each amount |     -- Add the elision strings (if any) to each amount | ||||||
|  | |||||||
| @ -221,3 +221,16 @@ hledger bal -f - | |||||||
| 	b  -,100.0 EUR | 	b  -,100.0 EUR | ||||||
| >>> | >>> | ||||||
| >>>=1 | >>>=1 | ||||||
|  | 
 | ||||||
|  | # 20. long numbers in multi balance reports | ||||||
|  | hledger bal -YN -f - | ||||||
|  | <<< | ||||||
|  | 2021-01-01 | ||||||
|  |     (a)      -0.12345678901234567890123456 EUR | ||||||
|  | >>> | ||||||
|  | Balance changes in 2021: | ||||||
|  | 
 | ||||||
|  |    ||                              2021  | ||||||
|  | ===++=================================== | ||||||
|  |  a || -0.12345678901234567890123456 EUR  | ||||||
|  | >>>=0 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user