@@ -153,12 +153,20 @@ splitTextBy isSep t
153153 in first : splitTextBy isSep (T.dropWhile isSep rest)
154154
155155splitTextByIndices :: [Int] -> T.Text -> [T.Text]
156−splitTextByIndices ns = splitTextByRelIndices (zipWith (-) ns (0:ns))
156+splitTextByIndices ns = splitTextByRelIndices (zipWith (-) ns (0:ns)) . T.unpack
157157 where
158− splitTextByRelIndices [] t = [t]
159− splitTextByRelIndices (x:xs) t =
160− let (first, rest) = T.splitAt x t
161− in first : splitTextByRelIndices xs rest
158+ splitTextByRelIndices [] cs = [T.pack cs]
159+ splitTextByRelIndices (x:xs) cs =
160+ let (first, rest) = splitAt' x cs
161+ in T.pack first : splitTextByRelIndices xs rest
162+
163+-- Note: don't replace this with T.splitAt, which is not sensitive
164+-- to character widths!
165+splitAt' :: Int -> [Char] -> ([Char],[Char])
166+splitAt' _ [] = ([],[])
167+splitAt' n xs | n <= 0 = ([],xs)
168+splitAt' n (x:xs) = (x:ys,zs)
169+ where (ys,zs) = splitAt' (n - charWidth x) xs
162170
163171ordNub :: (Ord a) => [a] -> [a]
164172ordNub l = go Set.empty l