Skip to content

Commit

Permalink
added-lines feature changed to only support safe case when recognize …
Browse files Browse the repository at this point in the history
…both sides added lines before and after
  • Loading branch information
yairchu committed Sep 20, 2024
1 parent 9d0a844 commit 9b245da
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
10 changes: 1 addition & 9 deletions src/Resolution.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,11 @@ resolveGenLines opts sides@(Sides a base b) =
_ | opts.addedLines ->
case addedBothSides a b <> addedBothSides b a of
[x] -> Just x
_ ->
case res a b <> res b a of
[x] -> Just x
_ -> Nothing
_ -> Nothing
_ -> Nothing
where
n = length base
addedBothSides x y = [x <> drop n y | drop (length x - n) x == base && take n y == base]
res x y =
[y <> drop n x | take n x == base] <>
[take initLen x <> y | drop initLen x == base]
where
initLen = length x - n

resolveConflict :: ResolutionOptions -> Conflict -> Resolution
resolveConflict opts c
Expand Down
3 changes: 2 additions & 1 deletion src/ResolutionOpts.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ parser =
"Convert tabs to the spaces at the tab stops for the given tab size"
(\x -> "Disable converting tabs to " <> show x <> " spaces at the tab stops")
<*> OptUtils.envSwitch "line-endings" True "line-ending characters conflict resolution"
<*> OptUtils.envSwitch "added-lines" False "added lines resolution (EXPERIMENTAL)"
<*> OptUtils.envSwitch "lines-added-around" False
"resolve conflicts where one change prepended lines to the base and the other appended"
<*> OptUtils.envSwitch "split-markers" False "split conflicts at tilde-split-markers"

isResolving :: ResolutionOptions -> Bool
Expand Down

0 comments on commit 9b245da

Please sign in to comment.