Oh, sorry.
enter the text shown in the screenshots, place the cursor on line 4 of file_a.txt ("cb"), press <Leader>mda to "mark diff alignment". Go to line 2 of file_b.txt and again type <Leader>mda> to indicate that those two points correspond to each other. Then run :diffupdate.
I think I have logic in there that ignores all the alignment points if there aren't the same number in each buffer but I'm not sure if I got around to that.
> BTW: attached is a patch, that prevents the use of using diffexpr for
> checking if diff really works (using the "line1" vs. "line2" check):
>
I don't think that's a very good idea, what if somebody uses diffexpr to specify the full path to diff? Or to use a separate program entirely, and they don't even have diff installed on their system? Then the test will always fail, right?
But it should be documented by diffexpr how the test actually works, it took me quite by surprise.
Oops, actually attaching the images would probably help.
OK, so Vim can still combine adjacent blocks. But can it be be updated to use this assumption, yet correctly handle any valid ed-style diff (in terms of adding diff filler and alignment of lines which are part of the same hunk in the diff)?
I certainly have no problem with do/dp getting the entire combination of changes for adjacent hunks, I just want Vim to show me the effect of those hunks properly.
Actually the current patch does cause one problem, as I noted earlier in the thread. Somehow the leading diff filler is missing but the changes are aligned anyway, causing one of the windows to jump out of alignment when switching back and forth between them.
> Changing the assumption is tricky, it might work in some cases but not
> always. It may cause problems for commands like "do" and "dp".
> We would at least need some good tests to make sure nothing breaks.
>
What sort of tests would you want to see? Make a diffexpr to return adjacent diffs and test that do, dp, :diffget, and :diffput still work on those blocks and also non-adjacent ones? Repeat with default diff output?
I've never messed with the test suite before (does it work on Windows?) but I'd be willing to look into it if there's a patch to support adjacent-but-separate hunks in the diff output.
Why is a diff with adjacent blocks not valid? How do you know a posix-compliant diff will never produce it? I don't see anything in man pages online about limitations on adjacent hunks. I Googled for "posix diff format" and looked at:
http://www.unix.com/man-page/posix/1posix/diff/
http://pubs.opengroup.org/onlinepubs/007904875/utilities/diff.html
http://pubs.opengroup.org/onlinepubs/007908799/xcu/diff.html
http://www.gnu.org/software/hello/manual/diff.html#Detailed%20ed
Even if diff itself only finds non-overlapping sections due to the algorithm used ( http://en.wikipedia.org/wiki/Diff#Algorithm ), the *output format* does not have this limitation. Indeed, rather than a single "change" operation, a diff tool could decide to output both a deletion and an addition at the same location, and as far as I can tell this should be considered valid input. Handling this last scenario might very well break what I'm trying to do anyway, but even so, Vim should not completely fail to highlight the second file as shown in the screenshots I posted earlier. And, I think it should be possible to handle such situations and still align lines affected by a "change" action in the diff.