Blame SOURCES/7.4.532

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