1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 16:02:43 +03:00

Guarantee non-empty by prepending.

This commit is contained in:
Rob Rix 2016-05-13 18:38:19 -04:00
parent c02e6c80a5
commit 9567c44c57

View File

@ -130,8 +130,8 @@ data PrettyDiff = PrettyDiff { unPrettySources :: Both (Source.Source Char), unP
deriving Eq
instance Show PrettyDiff where
show (PrettyDiff sources lines) = showLine (fromMaybe 0 (maximum (fmap length <$> shownLines))) <$> catMaybes shownLines >>= ('\n':)
where shownLines = toBoth <$> lines
show (PrettyDiff sources lines) = showLine (maximum (0 : (length <$> shownLines))) <$> shownLines >>= ('\n':)
where shownLines = catMaybes $ toBoth <$> lines
showLine n line = uncurry ((++) . (++ " | ")) (fromThese (replicate n ' ') (replicate n ' ') (runJoin (pad n <$> line)))
showDiff diff = filter (/= '\n') . toList . Source.slice (getRange diff)
pad n string = showString (take n string) (replicate (max 0 (n - length string)) ' ')