If there is exactly one conflicting change on the page that consists of an addition from both conflicting users and the page is a discussion page and the changes were attempted to be at the exact same spot it should be easy to merge it. So in that case we can suggest a resolution in a reduced interface.
The relevant line of code in the existing code is where a new \Diff() is created and processed in LineBasedUnifiedDiffFormatter::format(). The detection algorithm would do something very similar:
- Create two of these Diff objects, one from the base to the first edit, another one from the same base to the conflicting edit.
- Compare the two Diff. Both must start with a "copy" block that does have the exact same content (same number of lines), followed by an "add" block (doesn't matter how long it is), followed by another "copy" block (must be identical again).
( from T239792#5785392 )