mirror of
https://github.com/aelve/guide.git
synced 2024-11-22 11:33:34 +03:00
Show insertion/deletion places in diffs
This commit is contained in:
parent
1c5512cd68
commit
0a48a8e2be
@ -65,8 +65,9 @@ diffR = concatMap hunkToChunk . toList
|
||||
hunkToChunk (v, PV.Inserted) = [Added (tconcat v)]
|
||||
hunkToChunk (v, PV.Replaced) = [Added (tconcat v)]
|
||||
hunkToChunk (v, PV.Unchanged) = map Plain (toList v)
|
||||
hunkToChunk (_, PV.Deleted) = [] -- because it's not present
|
||||
-- in the right part
|
||||
-- it's useful to report deleted things as well because then we can mark
|
||||
-- them with tiny rectangles like “insert here”
|
||||
hunkToChunk (_, PV.Deleted) = [Added ""]
|
||||
|
||||
-- | Create a diff for the left (original) part. We only want to highlight
|
||||
-- parts which were deleted or replaced.
|
||||
@ -83,8 +84,7 @@ diffL = concatMap hunkToChunk
|
||||
hunkToChunk (v, PV.Inserted) = [Deleted (tconcat v)]
|
||||
hunkToChunk (v, PV.Replaced) = [Deleted (tconcat v)]
|
||||
hunkToChunk (v, PV.Unchanged) = map Plain (toList v)
|
||||
hunkToChunk (_, PV.Deleted) = [] -- because it's not present
|
||||
-- in the left part
|
||||
hunkToChunk (_, PV.Deleted) = [Deleted ""]
|
||||
|
||||
-- | In a bunch of chunks, find only the part that was changed
|
||||
trimDiff
|
||||
|
@ -512,9 +512,11 @@ renderDiff old new =
|
||||
mapM_ renderChunk diffRight
|
||||
toHtml (mconcat (take 10 diffContextBelow)) >> " [...]"
|
||||
--
|
||||
renderChunk (Diff.Added x) = ins_ (toHtml (showNewlines x))
|
||||
renderChunk (Diff.Deleted x) = del_ (toHtml (showNewlines x))
|
||||
renderChunk (Diff.Plain x) = toHtml x
|
||||
renderChunk (Diff.Added "") = ins_ [class_ "empty-chunk"] ""
|
||||
renderChunk (Diff.Added x) = ins_ (toHtml (showNewlines x))
|
||||
renderChunk (Diff.Deleted "") = del_ [class_ "empty-chunk"] ""
|
||||
renderChunk (Diff.Deleted x) = del_ (toHtml (showNewlines x))
|
||||
renderChunk (Diff.Plain x) = toHtml x
|
||||
--
|
||||
showNewlines x =
|
||||
let
|
||||
|
@ -77,6 +77,12 @@ textarea:focus {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
#edits .empty-chunk {
|
||||
padding-right: 5px;
|
||||
border: 1px dashed black;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
#stats table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
|
Loading…
Reference in New Issue
Block a user