Christian Brabandt wrote:

> there is a problem with getcurpos() and the matchparen plugin.
> 
> Consider this:
> 
> vim -u NONE -N -c 'ru plugin/matchparen.vim'
> Type iaaaa{<enter>}<enter>aaaa
> 
> At this point, press CursorUp twice in insert mode. Note, the cursor
> will be at column 2 instead of column 5.
> 
> The problem is the matchparen plugin:
> 
> ,----
> | fu! s:Highlight_Matching_Pair()
> |     if before > 0
> |       let has_getcurpos = exists("*getcurpos")
> |       if has_getcurpos
> |         " getcurpos() is more efficient but doesn't exist before 7.4.313.
> |         let save_cursor = getcurpos()
> |       else
> |         let save_cursor = winsaveview()
> |       endif
> |       call cursor(c_lnum, c_col - before)
> |     endif
> |     [...]
> |     if before > 0
> |       if has_getcurpos
> |         call setpos('.', save_cursor)
> |       else
> |         call winrestview(save_cursor)
> |       endif
> |     endif
> |     [...]
> | endfu
> `----
> 
> 
> When the function finishes, the setpos() call will correctly set the
> curwin->w_curswant column. Unfortunately, the cursor() function resets
> the curwin->w_set_curswant flag to TRUE, so that in the next loop in
> edit() curwin->w_curswant will be newly recalculated at edit() (Line 759
> update_curswant()) and therefore invalidate the curswant argument from 
> the setpos() call.
> 
> Interestingly, this does not happen with older Vims, that do not have 
> the getcurpos() function. Because in that case the winrestview() 
> function will be called, which resets the curwin->w_set_curswant flag to 
> FALSE and then the problem does not occur.
> 
> I think, the setpos() function should also reset curwin->w_curswant, if 
> curswant argument has been given:
> 
> diff --git a/src/eval.c b/src/eval.c
> --- a/src/eval.c
> +++ b/src/eval.c
> @@ -17375,7 +17375,10 @@ f_setpos(argvars, rettv)
>                 {
>                     curwin->w_cursor = pos;
>                     if (curswant >= 0)
> +                   {
>                         curwin->w_curswant = curswant - 1;
> +                       curwin->w_set_curswant = FALSE;
> +                   }
>                     check_cursor();
>                     rettv->vval.v_number = 0;
>                 }
> 
> Alternatively, one could change the matchparen plugin like this:

That looks a bit clumsy.  The above should be OK.

-- 
hundred-and-one symptoms of being an internet addict:
149. You find your computer sexier than your girlfriend

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

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