@@ -45,6 +45,17 @@ mkRanges pairs =
4545
4646 in go Nothing [] convertedPairs
4747
48+-- The uppermost code point to consider when building Unicode width
49+-- tables.
50+--
51+-- This only covers some of the possible Unicode range and is sure to
52+-- become stale eventually. Granted, at the time of this writing, even
53+-- the latest version of Unicode (13) totals 143,859 characters and that
54+-- only gets us to code point 0x231f3 or so. But it's only a matter of
55+-- time before this bound is too low.
56+unicodeTableUpperBound :: Char
57+unicodeTableUpperBound = '\x2FFFF'
58+
4859-- | Construct a unicode character width table by querying the terminal
4960-- connected to stdout. This works by emitting characters to stdout
5061-- and then querying the terminal to determine the resulting cursor
@@ -53,13 +64,7 @@ mkRanges pairs =
5364-- system performance.
5465buildUnicodeWidthTable :: IO UnicodeWidthTable
5566buildUnicodeWidthTable = do
56− -- NB: this only covers some of the possible Unicode range and is
57− -- sure to become stale eventually. Granted, at the time of this
58− -- writing, even the latest version of Unicode (13) totals 143,859
59− -- characters and that only gets us to code point 0x231f3 or so. But
60− -- it's only a matter of time before the bound in this loop is too
61− -- low.
62− pairs <- fmap catMaybes $ forM ['\0'..'\x2FFFF'] $ \i ->
67+ pairs <- fmap catMaybes $ forM ['\0'..unicodeTableUpperBound] $ \i ->
6368 if shouldConsider i
6469 then (Just . (i,)) <$> charWidth i
6570 else return Nothing