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