diff --git a/prettyprinter/src/Prettyprinter/Internal.hs b/prettyprinter/src/Prettyprinter/Internal.hs index 63602c2d..8b70fa20 100755 --- a/prettyprinter/src/Prettyprinter/Internal.hs +++ b/prettyprinter/src/Prettyprinter/Internal.hs @@ -491,7 +491,9 @@ unsafeTextWithoutNewlines text = case T.uncons text of -- unsafeTextWithLength "😃" (realLength "😃") -- @ unsafeTextWithLength :: Text -> Int -> Doc ann -unsafeTextWithLength txt l = Text l txt +unsafeTextWithLength txt l | T.null txt = Empty + | l == 1 && T.length txt == 1 = Char (T.head txt) -- no wide character or control + | otherwise = Text l txt -- | The empty document behaves like @('pretty' "")@, so it has a height of 1. -- This may lead to surprising behaviour if we expect it to bear no weight