1
1
mirror of https://github.com/github/semantic.git synced 2024-11-29 02:44:36 +03:00

Define nextChange in terms of changeIncludingContext.

This commit is contained in:
Rob Rix 2015-12-30 17:43:46 -05:00
parent 4e10072341
commit ed9b57af4e

View File

@ -84,11 +84,10 @@ nextHunk start rows = case contiguousChanges start rows of
else last
nextChange :: (Sum Int, Sum Int) -> [Row (SplitDiff a Info)] -> Maybe ((Sum Int, Sum Int), Change (SplitDiff a Info), [Row (SplitDiff a Info)])
nextChange start rows = case changes of
[] -> Nothing
_ -> Just (start <> mconcat (rowLength <$> skippedContext), Change leadingContext changes, afterChanges)
where (leadingRows, afterLeadingContext) = break rowHasChanges rows
(changes, afterChanges) = span rowHasChanges afterLeadingContext
nextChange start rows = case changeIncludingContext leadingContext of
Nothing -> Nothing
Just (change, afterChanges) -> Just (start <> mconcat (rowLength <$> skippedContext), change, afterChanges)
where (leadingRows, _) = break rowHasChanges rows
(skippedContext, leadingContext) = splitAt (max (length leadingRows - 3) 0) leadingRows
changeIncludingContext :: [Row (SplitDiff a Info)] -> Maybe (Change (SplitDiff a Info), [Row (SplitDiff a Info)])