Hi Gary!

On Di, 01 Sep 2015, Gary Johnson wrote:

> On 2015-09-01, Bram Moolenaar wrote:
> > Patch 7.4.853
> > Problem:    "zt" in diff mode does not always work properly. (Gary Johnson)
> > Solution:   Don't count filler lines twice. (Christian Brabandt)
> > Files:      src/move.c
> 
> >   #ifdef FEAT_DIFF
> > !     /* used already contains the number of filler lines above, don't add 
> > it
> > !      * again.
> > !      * TODO: if filler lines above new top are to be considered as 
> > context for
> > !      * the current window, leave next statement commented, else hide 
> > filler
> > !      * lines above cursor line, by adding them to extra */
> > !     /* extra += diff_check_fill(curwin, curwin->w_cursor.lnum); */
> >   #endif
> 
> Thanks for this change.  I think it would work better and as I think
> "zt" should if that line was uncommented.
> 
> Even then, though, there is a bug in the behavior.  It was in
> Christian's original patch, too--I just didn't notice it until I
> started testing this patch.
> 
> With the cursor on the line immediately below the fill lines, "zt"
> moves the line to the top of the window.  It also works when the
> cursor is on the third line and farther below the fill lines.  But
> when the cursor is on the second line below the fill lines, "zt"
> moves the line to the middle of the window.
> 
> Here's a demonstration.
> 
>     $ vimdiff -N -u NONE -c 'set foldlevel=99' +201 <(seq 200; seq 301 500) 
> <(seq 500)
> 
> The cursor should be on line 201 in the left window, which contains
> the text "301".  Type zt and notice that the line with "301" moves
> to the top of the window.  Move the cursor down one line to the
> "302" and type zt again.  This time the line moved to the center of
> the window.  Move the cursor down one line to the "303", type zt
> again, and notice that the line moves to the top of the window.
> Typing zt on any line containing "301" or greater correctly (IMO)
> moves the line to the top of the window, _except_ for the line
> containing "302".

I see the problem:
diff --git a/src/move.c b/src/move.c
--- a/src/move.c
+++ b/src/move.c
@@ -1756,7 +1756,7 @@ scroll_cursor_top(min_scroll, always)
      * TODO: if filler lines above new top are to be considered as context for
      * the current window, leave next statement commented, else hide filler
      * lines above cursor line, by adding them to extra */
-    /* extra += diff_check_fill(curwin, curwin->w_cursor.lnum); */
+     extra += diff_check_fill(curwin, curwin->w_cursor.lnum);
 #endif

     /*
@@ -1771,7 +1771,7 @@ scroll_cursor_top(min_scroll, always)
            i = 1;
        else
 #endif
-           i = plines(top);
+           i = plines_nofill(top);
        used += i;
        if (extra + i <= off && bot < curbuf->b_ml.ml_line_count)
        {


Best,
Christian
-- 
Wenn einem das Wasser bis zum Hals steht, dann sollte man den Kopf
nicht hängen lassen.
                -- Jürgen Becker

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui