Hi Ben!

On So, 10 Jun 2012, Ben Fritz wrote:

> On Sunday, June 10, 2012 7:52:37 AM UTC-5, Christian Brabandt wrote:
> > How did you generate the aligned.patch file? No matter what I do, for me 
> > the plugin always generates:
> > 
> > 2,7c2,4
> > < a
> > < b
> > < cb
> > < db
> > < eb
> > < f
> > ---
> > > cc
> > > dd
> > > ee
> > 
> > But perhaps, I'm using your plugin wrongly, e.g. how many alignemnt 
> > points do I have to set and where? But even after I manually copied the 
> > aligned.patch file over the resulting file, Vim still gets the alignment 
> > wrong.
> > 
> 
> 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 did that. I still get the above patch.  Ah, I found the problem. You 
are parsing the output of sign place, and on my localized version it 
prints:

:sign place
--- Zeichen ---
Zeichen für ../diff1.txt:
    Zeile=2  id=1339437602  Name=manDiffAlign01
Zeichen für ../diff2.txt:
    Zeile=4  id=1339437599  Name=manDiffAlign01

So it is probably better to look for the first equal sign.

After changing my Vim to an english localization I could reproduce your 
issue. I think the problem is, that Vim thinks, the 2 diff regions are 
overlapping. This looks like an "off-by 1" error for me, and indeed this 
patch fixes it for me:

diff --git a/src/diff.c b/src/diff.c
--- a/src/diff.c
+++ b/src/diff.c
@@ -1318,8 +1318,8 @@
        }
 
        if (dp != NULL
-               && lnum_orig <= dp->df_lnum[idx_orig] + dp->df_count[idx_orig]
-               && lnum_orig + count_orig >= dp->df_lnum[idx_orig])
+               && lnum_orig < dp->df_lnum[idx_orig] + dp->df_count[idx_orig]
+               && lnum_orig + count_orig > dp->df_lnum[idx_orig])
        {
            /* New block overlaps with existing block(s).
             * First find last block that overlaps. */

> > 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?

Good point, indeed.

> But it should be documented by diffexpr how the test actually works,
> it took me quite by surprise.

Yes, this looks unsurprisingly when first using 'diffexpr'.

regards,
Christian

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui