From 871889cac2baae4bd9d8a6059f916162cd2c6d07 Mon Sep 17 00:00:00 2001 From: Yair Chuchem Date: Mon, 25 Nov 2024 13:38:32 +0200 Subject: [PATCH] Prep for possible language-aware conflict splitting --- src/Resolution.hs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/Resolution.hs b/src/Resolution.hs index 7268dc3..efd04aa 100644 --- a/src/Resolution.hs +++ b/src/Resolution.hs @@ -163,18 +163,20 @@ resolveContent opts = foldMap go where go (Left line) = NewContent mempty (unlines [line]) - go (Right conflict) - | opts.splitMarkers = - r - { result = - if r.result.failedToResolve + r.result.reducedConflicts > 0 - then mempty {reducedConflicts = 1} -- The split is a reduction - else mempty {resolvedSuccessfully = 1} - } - | otherwise = resolve conflict - where - s = splitConflict conflict - r = foldMap resolve s + go (Right conflict) = + r + { result = + case parts of + [_] -> r.result + _ | r.result.failedToResolve + r.result.reducedConflicts > 0 -> + mempty {reducedConflicts = 1} -- The split is a reduction + | otherwise -> mempty {resolvedSuccessfully = 1} + } + where + parts + | opts.splitMarkers = splitConflict conflict + | otherwise = [conflict] + r = foldMap resolve parts resolve conflict = formatResolution $ resolveConflict opts $ (if opts.lineEndings then lineBreakFix else id) $