On Feb 4, 6:19 pm, Andy Wokula <[EMAIL PROTECTED]> wrote:
> ap schrieb:
>
>
>
> > Hi ,
>
> > I think I found a bug in the search() function.
> > X marks the spot (cursor).
>
> > X         a
> > c         Y
>
> > :call search('\_s*a\_s*','e')
>
> > It seems that search() skips a character under this circumstances,
> > or sets the end at the wrong place.  The cursor will be positioned
> > at the last col in line2 (Y) which is wrong, because the pattern
> > can't possibly match a 'c'.  I have a strong feeling this has
> > something to do with the newline atom :-).
>
> > -ap
>
> Same (start at X, stop at Y) for
>     :call search("^", "e")
>     :call search("^", "ce")
>
> --
> Andy

*** ../../clean/vim7/src/search.c       2008-01-26 21:15:46.000000000 +0100
--- search.c    2008-02-05 13:38:47.570525616 +0100
***************
*** 833,842 ****
                            continue;
                    }

!                   if (options & SEARCH_END && !(options & SEARCH_NOOF))
                    {
                        pos->lnum = lnum + endpos.lnum;
!                       pos->col = endpos.col - 1;
  #ifdef FEAT_MBYTE
                        if (has_mbyte)
                        {
--- 833,853 ----
                            continue;
                    }

!                   /* Don't do this for zerowidth matches. */
!                   if (options & SEARCH_END && !(options & SEARCH_NOOF)
!                           && !(matchpos.lnum == endpos.lnum && matchpos.col ==
endpos.col))
                    {
+                       /* If the match ends in the 1st col, set it
+                        * to the last one in the previous line.
+                        * */
                        pos->lnum = lnum + endpos.lnum;
!                       if ( endpos.col == 0 )
!                       {
!                           --pos->lnum;
!                           pos->col = (colnr_T)STRLEN(ml_get_buf(buf, 
pos->lnum,
FALSE));
!                       }
!                       else
!                           pos->col = endpos.col - 1;
  #ifdef FEAT_MBYTE
                        if (has_mbyte)
                        {


endpos->col will be 0 in this scenarios. Substract 1 and it will
become a huge number,
because col is an unsigned int. The correct value for pos would be the
last col of
the previous line. However I am not certain this is the right way to
do this.

There is another problem :

--------------
a
a
-------------

call search('a\_s*','ew')
will never wrap in this case.

-ap

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui