From 2065b3c41ecd53002bd23d77fcf30e2bb7dade14 Mon Sep 17 00:00:00 2001 From: Jaro Date: Fri, 10 Mar 2023 09:42:41 +0100 Subject: [PATCH] Remove redundant overflow handling. This may be useful later when words are allowed to overflow, but this code path is currently unused. --- src/Data/Text/ParagraphLayout/Internal/Plain.hs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Data/Text/ParagraphLayout/Internal/Plain.hs b/src/Data/Text/ParagraphLayout/Internal/Plain.hs index 9392d2c..19243e5 100644 --- a/src/Data/Text/ParagraphLayout/Internal/Plain.hs +++ b/src/Data/Text/ParagraphLayout/Internal/Plain.hs @@ -100,15 +100,11 @@ layoutLines maxWidth runs | null rest -- Everything fits. We are done. = fitting : [] - | null fitting - -- Nothing fits. We must resolve this by overflowing. - = overflowing : [] | otherwise -- Something fits, the rest goes on the next line. = fitting : layoutLines maxWidth rest where (fitting, rest) = layoutAndWrapRunsH maxWidth runs - overflowing = layoutRunsH runs -- TODO: Allow a run across multiple spans (e.g. if they only differ by colour). @@ -123,7 +119,10 @@ positionLineH :: Int32 -> [WithSpan PF.ProtoFragment] -> (Int32, [WithSpan Fragment]) positionLineH originY pfs = (nextY, frags) where - nextY = maximum $ map y_min rects + -- A line with no glyphs will be considered to have zero height. + -- This can happen when line breaking produces a line that contains + -- onls spaces. + nextY = if null rects then originY else maximum $ map y_min rects rects = map (\(WithSpan _ r) -> fragmentRect r) frags frags = snd $ mapAccumL (positionFragmentH originY) originX pfs originX = paragraphOriginX -- 2.30.2