073263
To: vim_dev@googlegroups.com
073263
Subject: Patch 7.4.532
073263
Fcc: outbox
073263
From: Bram Moolenaar <Bram@moolenaar.net>
073263
Mime-Version: 1.0
073263
Content-Type: text/plain; charset=UTF-8
073263
Content-Transfer-Encoding: 8bit
073263
------------
073263
073263
Patch 7.4.532
073263
Problem:    When using 'incsearch' "2/pattern/e" highlights the first match.
073263
Solution:   Move the code to set extra_col inside the loop for count.  (Ozaki
073263
	    Kiichi)
073263
Files:	    src/search.c
073263
073263
073263
*** ../vim-7.4.531/src/search.c	2014-06-17 13:50:06.148087184 +0200
073263
--- src/search.c	2014-11-27 17:21:49.579489220 +0100
073263
***************
073263
*** 552,557 ****
073263
--- 552,558 ----
073263
      int		match_ok;
073263
      long	nmatched;
073263
      int		submatch = 0;
073263
+     int		first_match = TRUE;
073263
      int		save_called_emsg = called_emsg;
073263
  #ifdef FEAT_SEARCH_EXTRA
073263
      int		break_loop = FALSE;
073263
***************
073263
*** 565,597 ****
073263
  	return FAIL;
073263
      }
073263
  
073263
-     /* When not accepting a match at the start position set "extra_col" to a
073263
-      * non-zero value.  Don't do that when starting at MAXCOL, since MAXCOL +
073263
-      * 1 is zero. */
073263
-     if ((options & SEARCH_START) || pos->col == MAXCOL)
073263
- 	extra_col = 0;
073263
- #ifdef FEAT_MBYTE
073263
-     /* Watch out for the "col" being MAXCOL - 2, used in a closed fold. */
073263
-     else if (dir != BACKWARD && has_mbyte
073263
- 		    && pos->lnum >= 1 && pos->lnum <= buf->b_ml.ml_line_count
073263
- 						     && pos->col < MAXCOL - 2)
073263
-     {
073263
- 	ptr = ml_get_buf(buf, pos->lnum, FALSE) + pos->col;
073263
- 	if (*ptr == NUL)
073263
- 	    extra_col = 1;
073263
- 	else
073263
- 	    extra_col = (*mb_ptr2len)(ptr);
073263
-     }
073263
- #endif
073263
-     else
073263
- 	extra_col = 1;
073263
- 
073263
      /*
073263
       * find the string
073263
       */
073263
      called_emsg = FALSE;
073263
      do	/* loop for count */
073263
      {
073263
  	start_pos = *pos;	/* remember start pos for detecting no match */
073263
  	found = 0;		/* default: not found */
073263
  	at_first_line = TRUE;	/* default: start in first line */
073263
--- 566,598 ----
073263
  	return FAIL;
073263
      }
073263
  
073263
      /*
073263
       * find the string
073263
       */
073263
      called_emsg = FALSE;
073263
      do	/* loop for count */
073263
      {
073263
+ 	/* When not accepting a match at the start position set "extra_col" to
073263
+ 	 * a non-zero value.  Don't do that when starting at MAXCOL, since
073263
+ 	 * MAXCOL + 1 is zero. */
073263
+ 	if ((options & SEARCH_START) || pos->col == MAXCOL)
073263
+ 	    extra_col = 0;
073263
+ #ifdef FEAT_MBYTE
073263
+ 	/* Watch out for the "col" being MAXCOL - 2, used in a closed fold. */
073263
+ 	else if (dir != BACKWARD && has_mbyte
073263
+ 		     && pos->lnum >= 1 && pos->lnum <= buf->b_ml.ml_line_count
073263
+ 						     && pos->col < MAXCOL - 2)
073263
+ 	{
073263
+ 	    ptr = ml_get_buf(buf, pos->lnum, FALSE) + pos->col;
073263
+ 	    if (*ptr == NUL)
073263
+ 		extra_col = 1;
073263
+ 	    else
073263
+ 		extra_col = (*mb_ptr2len)(ptr);
073263
+ 	}
073263
+ #endif
073263
+ 	else
073263
+ 	    extra_col = 1;
073263
+ 
073263
  	start_pos = *pos;	/* remember start pos for detecting no match */
073263
  	found = 0;		/* default: not found */
073263
  	at_first_line = TRUE;	/* default: start in first line */
073263
***************
073263
*** 677,683 ****
073263
  			 * otherwise "/$" will get stuck on end of line.
073263
  			 */
073263
  			while (matchpos.lnum == 0
073263
! 				&& ((options & SEARCH_END)
073263
  				    ?  (nmatched == 1
073263
  					&& (int)endpos.col - 1
073263
  					     < (int)start_pos.col + extra_col)
073263
--- 678,684 ----
073263
  			 * otherwise "/$" will get stuck on end of line.
073263
  			 */
073263
  			while (matchpos.lnum == 0
073263
! 				&& ((options & SEARCH_END) && first_match
073263
  				    ?  (nmatched == 1
073263
  					&& (int)endpos.col - 1
073263
  					     < (int)start_pos.col + extra_col)
073263
***************
073263
*** 908,913 ****
073263
--- 909,915 ----
073263
  		    pos->coladd = 0;
073263
  #endif
073263
  		    found = 1;
073263
+ 		    first_match = FALSE;
073263
  
073263
  		    /* Set variables used for 'incsearch' highlighting. */
073263
  		    search_match_lines = endpos.lnum - matchpos.lnum;
073263
*** ../vim-7.4.531/src/version.c	2014-11-27 16:38:07.652261234 +0100
073263
--- src/version.c	2014-11-27 17:29:13.762616760 +0100
073263
***************
073263
*** 743,744 ****
073263
--- 743,746 ----
073263
  {   /* Add new patch number below this line */
073263
+ /**/
073263
+     532,
073263
  /**/
073263
073263
-- 
073263
The most powerful force in the universe is gossip.
073263
073263
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
073263
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
073263
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
073263
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///