aberteau / DiffPatch

Diff parsing and patching with .Net
https://amaelberteau.com/project/diffpatch
MIT License
20 stars 5 forks source link

[FEATURE REQUEST] Add line offset correction when patching with context diffs #10

Open PGgamer2 opened 2 months ago

PGgamer2 commented 2 months ago

As stated in the patch manual:

With context diffs, and to a lesser extent with normal diffs, patch can detect when the line numbers mentioned in the patch are incorrect, and attempts to find the correct place to apply each hunk of the patch. As a first guess, it takes the line number mentioned for the hunk, plus or minus any offset used in applying the previous hunk. If that is not the correct place, patch scans both forwards and backwards for a set of lines matching the context given in the hunk. First patch looks for a place where all lines of the context match. If no such place is found, and it's a context diff, and the maximum fuzz factor is set to 1 or more, then another scan takes place ignoring the first and last line of context. If that fails, and the maximum fuzz factor is set to 2 or more, the first two and last two lines of context are ignored, and another scan is made. (The default maximum fuzz factor is 2.)

This feature would greatly improve the package

aberteau commented 2 months ago

Hi @PGgamer2,

Thank you for this issue. I have to admit that it's been a long time since I got my hands on this library. πŸ˜… I'll have to dive back into it. I'll see what I can do.

In the meantime, if you have an idea of ​​what changes should be made, feel free to submit a pull request. πŸ˜‰

Regards, Amael