Skip to content

Commit 3f22f11

Browse files
committed
Fix highlighting of the 'Merge:' line in merge commits
1 parent c51aefe commit 3f22f11

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

src/Fancydiff/AnsiFormatting.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ data RenderedPalette = RenderedPalette {
4141
, p'parentheses :: {-# UNPACK #-} !Text
4242
, p'ignore :: {-# UNPACK #-} !Text
4343
, p'commitMain :: {-# UNPACK #-} !Text
44+
, p'commitMerge :: {-# UNPACK #-} !Text
4445
, p'commitOther :: {-# UNPACK #-} !Text
4546
, p'commitMsgByLines :: {-# UNPACK #-} !Text
4647
, p'diffMain :: {-# UNPACK #-} !Text
@@ -72,6 +73,8 @@ renderPalette brightness p = RenderedPalette
7273
, p'parentheses = front D.p'parentheses
7374
, p'ignore = front D.p'ignore
7475
, p'commitMain = wrap $ back D.p'commitMain
76+
, p'commitMerge = wrap $ T.concat [back D.p'commitMain,
77+
front D.p'commitMergeFG]
7578
, p'commitOther = wrap $ back D.p'commitOther
7679
, p'commitMsgByLines = front D.p'commitMsgByLines
7780
, p'diffMain = wrap $ back D.p'diffMain
@@ -170,6 +173,7 @@ ansiFormatting = root
170173
repr _ _ _ DiffNothing = Nothing
171174
repr _ _ _ CommitMsgByLines = Just $ p'commitMsgByLines pal
172175
repr _ _ _ CommitMain = Just $ p'commitMain pal
176+
repr _ _ _ CommitMerge = Just $ p'commitMerge pal
173177
repr _ _ _ CommitOther = Just $ p'commitOther pal
174178

175179
repr _ _ r (Style Ignore) = r

src/Fancydiff/Data.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ data Format
4343
| DiffUnchanged
4444
| DiffNothing
4545
| CommitMain
46+
| CommitMerge
4647
| CommitOther
4748
| CommitMsgByLines
4849
| Mark
@@ -79,6 +80,7 @@ data Palette a = Palette {
7980
, p'parentheses :: !a
8081
, p'ignore :: !a
8182
, p'commitMsgByLines :: !a
83+
, p'commitMergeFG :: !a
8284
, p'commitMain :: !a
8385
, p'commitOther :: !a
8486
, p'diffMain :: !a

src/Fancydiff/Lib.hs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,13 @@ commitHighlight commit = do
198198
where
199199
parsed = parse $ lineSplit commit
200200

201-
parse (x:xs) = case' "commit " (const FD.CommitMain) parse x xs $
202-
case' "Author: " (const FD.CommitOther) parse x xs $
203-
case' "AuthorDate: " (const FD.CommitOther) parse x xs $
204-
case' "Commit: " (const FD.CommitOther) parse x xs $
205-
case' "CommitDate: " (const FD.CommitOther) parse x xs $
206-
case' "Date: " (const FD.CommitOther) parse x xs $
201+
parse (x:xs) = case' "commit " (const FD.CommitMain) parse x xs $
202+
case' "Merge: " (const FD.CommitMerge) parse x xs $
203+
case' "Author: " (const FD.CommitOther) parse x xs $
204+
case' "AuthorDate: " (const FD.CommitOther) parse x xs $
205+
case' "Commit: " (const FD.CommitOther) parse x xs $
206+
case' "CommitDate: " (const FD.CommitOther) parse x xs $
207+
case' "Date: " (const FD.CommitOther) parse x xs $
207208
case' " Signed-off-by:" (const CommitMsgByLines) parse x xs $
208209
else' parse x xs
209210
parse [] = []

src/Fancydiff/Themes.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ darkBackground = Palette {
2525
, p'parentheses = ColorString "#c0f0f0"
2626
, p'ignore = ColorString "#ffffff"
2727
, p'commitMain = ColorString "#702070"
28+
, p'commitMergeFG = ColorString "#ffff00"
2829
, p'commitOther = ColorString "#502050"
2930
, p'commitMsgByLines = ColorString "#ffbbff"
3031
, p'diffMain = ColorString "#0020a0"

0 commit comments

Comments
 (0)