mirror of
https://github.com/github/semantic.git
synced 2024-12-25 07:55:12 +03:00
Simplify showLine a little further.
This commit is contained in:
parent
ce9be615a6
commit
3366b94b5a
@ -113,8 +113,7 @@ data PrettyDiff = PrettyDiff { unPrettySources :: Both (Source.Source Char), unP
|
||||
instance Show PrettyDiff where
|
||||
show (PrettyDiff sources lines) = showLine (fromMaybe 0 (maximum (fmap length <$> shownLines))) <$> catMaybes shownLines >>= ('\n':)
|
||||
where shownLines = toBoth <$> lines
|
||||
showLine n line = let (before, after) = fromThese (replicate n ' ') (replicate n ' ') (runJoin (pad n <$> line)) in
|
||||
before ++ " | " ++ after
|
||||
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)) ' ')
|
||||
toBoth them = showDiff <$> them `applyThese` modifyJoin (uncurry These) sources
|
||||
|
Loading…
Reference in New Issue
Block a user