Karsten Hopp b97b9a
To: vim_dev@googlegroups.com
Karsten Hopp b97b9a
Subject: Patch 7.4.636
Karsten Hopp b97b9a
Fcc: outbox
Karsten Hopp b97b9a
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp b97b9a
Mime-Version: 1.0
Karsten Hopp b97b9a
Content-Type: text/plain; charset=UTF-8
Karsten Hopp b97b9a
Content-Transfer-Encoding: 8bit
Karsten Hopp b97b9a
------------
Karsten Hopp b97b9a
Karsten Hopp b97b9a
Patch 7.4.636
Karsten Hopp b97b9a
Problem:    A search with end offset gets stuck at end of file. (Gary Johnson)
Karsten Hopp b97b9a
Solution:   When a search doesn't move the cursor repeat it with a higher
Karsten Hopp b97b9a
	    count. (Christian Brabandt)
Karsten Hopp b97b9a
Files:	    src/normal.c, src/testdir/test44.in, src/testdir/test44.ok
Karsten Hopp b97b9a
Karsten Hopp b97b9a
Karsten Hopp b97b9a
*** ../vim-7.4.635/src/normal.c	2015-01-27 20:59:26.496971751 +0100
Karsten Hopp b97b9a
--- src/normal.c	2015-02-17 15:43:29.216732977 +0100
Karsten Hopp b97b9a
***************
Karsten Hopp b97b9a
*** 100,106 ****
Karsten Hopp b97b9a
  static void	nv_dollar __ARGS((cmdarg_T *cap));
Karsten Hopp b97b9a
  static void	nv_search __ARGS((cmdarg_T *cap));
Karsten Hopp b97b9a
  static void	nv_next __ARGS((cmdarg_T *cap));
Karsten Hopp b97b9a
! static void	normal_search __ARGS((cmdarg_T *cap, int dir, char_u *pat, int opt));
Karsten Hopp b97b9a
  static void	nv_csearch __ARGS((cmdarg_T *cap));
Karsten Hopp b97b9a
  static void	nv_brackets __ARGS((cmdarg_T *cap));
Karsten Hopp b97b9a
  static void	nv_percent __ARGS((cmdarg_T *cap));
Karsten Hopp b97b9a
--- 100,106 ----
Karsten Hopp b97b9a
  static void	nv_dollar __ARGS((cmdarg_T *cap));
Karsten Hopp b97b9a
  static void	nv_search __ARGS((cmdarg_T *cap));
Karsten Hopp b97b9a
  static void	nv_next __ARGS((cmdarg_T *cap));
Karsten Hopp b97b9a
! static int	normal_search __ARGS((cmdarg_T *cap, int dir, char_u *pat, int opt));
Karsten Hopp b97b9a
  static void	nv_csearch __ARGS((cmdarg_T *cap));
Karsten Hopp b97b9a
  static void	nv_brackets __ARGS((cmdarg_T *cap));
Karsten Hopp b97b9a
  static void	nv_percent __ARGS((cmdarg_T *cap));
Karsten Hopp b97b9a
***************
Karsten Hopp b97b9a
*** 5765,5771 ****
Karsten Hopp b97b9a
  	init_history();
Karsten Hopp b97b9a
  	add_to_history(HIST_SEARCH, buf, TRUE, NUL);
Karsten Hopp b97b9a
  #endif
Karsten Hopp b97b9a
! 	normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0);
Karsten Hopp b97b9a
      }
Karsten Hopp b97b9a
      else
Karsten Hopp b97b9a
  	do_cmdline_cmd(buf);
Karsten Hopp b97b9a
--- 5765,5771 ----
Karsten Hopp b97b9a
  	init_history();
Karsten Hopp b97b9a
  	add_to_history(HIST_SEARCH, buf, TRUE, NUL);
Karsten Hopp b97b9a
  #endif
Karsten Hopp b97b9a
! 	(void)normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0);
Karsten Hopp b97b9a
      }
Karsten Hopp b97b9a
      else
Karsten Hopp b97b9a
  	do_cmdline_cmd(buf);
Karsten Hopp b97b9a
***************
Karsten Hopp b97b9a
*** 6301,6307 ****
Karsten Hopp b97b9a
  	return;
Karsten Hopp b97b9a
      }
Karsten Hopp b97b9a
  
Karsten Hopp b97b9a
!     normal_search(cap, cap->cmdchar, cap->searchbuf,
Karsten Hopp b97b9a
  						(cap->arg ? 0 : SEARCH_MARK));
Karsten Hopp b97b9a
  }
Karsten Hopp b97b9a
  
Karsten Hopp b97b9a
--- 6301,6307 ----
Karsten Hopp b97b9a
  	return;
Karsten Hopp b97b9a
      }
Karsten Hopp b97b9a
  
Karsten Hopp b97b9a
!     (void)normal_search(cap, cap->cmdchar, cap->searchbuf,
Karsten Hopp b97b9a
  						(cap->arg ? 0 : SEARCH_MARK));
Karsten Hopp b97b9a
  }
Karsten Hopp b97b9a
  
Karsten Hopp b97b9a
***************
Karsten Hopp b97b9a
*** 6313,6326 ****
Karsten Hopp b97b9a
  nv_next(cap)
Karsten Hopp b97b9a
      cmdarg_T	*cap;
Karsten Hopp b97b9a
  {
Karsten Hopp b97b9a
!     normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg);
Karsten Hopp b97b9a
  }
Karsten Hopp b97b9a
  
Karsten Hopp b97b9a
  /*
Karsten Hopp b97b9a
   * Search for "pat" in direction "dir" ('/' or '?', 0 for repeat).
Karsten Hopp b97b9a
   * Uses only cap->count1 and cap->oap from "cap".
Karsten Hopp b97b9a
   */
Karsten Hopp b97b9a
!     static void
Karsten Hopp b97b9a
  normal_search(cap, dir, pat, opt)
Karsten Hopp b97b9a
      cmdarg_T	*cap;
Karsten Hopp b97b9a
      int		dir;
Karsten Hopp b97b9a
--- 6313,6338 ----
Karsten Hopp b97b9a
  nv_next(cap)
Karsten Hopp b97b9a
      cmdarg_T	*cap;
Karsten Hopp b97b9a
  {
Karsten Hopp b97b9a
!     pos_T old = curwin->w_cursor;
Karsten Hopp b97b9a
!     int   i = normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg);
Karsten Hopp b97b9a
! 
Karsten Hopp b97b9a
!     if (i == 1 && equalpos(old, curwin->w_cursor))
Karsten Hopp b97b9a
!     {
Karsten Hopp b97b9a
! 	/* Avoid getting stuck on the current cursor position, which can
Karsten Hopp b97b9a
! 	 * happen when an offset is given and the cursor is on the last char
Karsten Hopp b97b9a
! 	 * in the buffer: Repeat with count + 1. */
Karsten Hopp b97b9a
! 	cap->count1 += 1;
Karsten Hopp b97b9a
! 	(void)normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg);
Karsten Hopp b97b9a
! 	cap->count1 -= 1;
Karsten Hopp b97b9a
!     }
Karsten Hopp b97b9a
  }
Karsten Hopp b97b9a
  
Karsten Hopp b97b9a
  /*
Karsten Hopp b97b9a
   * Search for "pat" in direction "dir" ('/' or '?', 0 for repeat).
Karsten Hopp b97b9a
   * Uses only cap->count1 and cap->oap from "cap".
Karsten Hopp b97b9a
+  * Return 0 for failure, 1 for found, 2 for found and line offset added.
Karsten Hopp b97b9a
   */
Karsten Hopp b97b9a
!     static int
Karsten Hopp b97b9a
  normal_search(cap, dir, pat, opt)
Karsten Hopp b97b9a
      cmdarg_T	*cap;
Karsten Hopp b97b9a
      int		dir;
Karsten Hopp b97b9a
***************
Karsten Hopp b97b9a
*** 6354,6359 ****
Karsten Hopp b97b9a
--- 6366,6372 ----
Karsten Hopp b97b9a
      /* "/$" will put the cursor after the end of the line, may need to
Karsten Hopp b97b9a
       * correct that here */
Karsten Hopp b97b9a
      check_cursor();
Karsten Hopp b97b9a
+     return i;
Karsten Hopp b97b9a
  }
Karsten Hopp b97b9a
  
Karsten Hopp b97b9a
  /*
Karsten Hopp b97b9a
*** ../vim-7.4.635/src/testdir/test44.in	2013-09-19 17:00:14.000000000 +0200
Karsten Hopp b97b9a
--- src/testdir/test44.in	2015-02-17 15:39:42.387675976 +0100
Karsten Hopp b97b9a
***************
Karsten Hopp b97b9a
*** 42,47 ****
Karsten Hopp b97b9a
--- 42,53 ----
Karsten Hopp b97b9a
  :put =matchstr(\"אבגד\", \"..\", 0, 2) " בג
Karsten Hopp b97b9a
  :put =matchstr(\"אבגד\", \".\", 0, 0) " א
Karsten Hopp b97b9a
  :put =matchstr(\"אבגד\", \".\", 4, -1) " ג
Karsten Hopp b97b9a
+ :new
Karsten Hopp b97b9a
+ :$put =['dog(a', 'cat(']
Karsten Hopp b97b9a
+ /(/e+
Karsten Hopp b97b9a
+ "ayn:bd!
Karsten Hopp b97b9a
+ :$put =''
Karsten Hopp b97b9a
+ G"ap
Karsten Hopp b97b9a
  :w!
Karsten Hopp b97b9a
  :qa!
Karsten Hopp b97b9a
  ENDTEST
Karsten Hopp b97b9a
*** ../vim-7.4.635/src/testdir/test44.ok	2013-05-26 14:16:28.000000000 +0200
Karsten Hopp b97b9a
--- src/testdir/test44.ok	2015-02-17 15:31:20.586185997 +0100
Karsten Hopp b97b9a
***************
Karsten Hopp b97b9a
*** 22,24 ****
Karsten Hopp b97b9a
--- 22,26 ----
Karsten Hopp b97b9a
  בג
Karsten Hopp b97b9a
  א
Karsten Hopp b97b9a
  ג
Karsten Hopp b97b9a
+ a
Karsten Hopp b97b9a
+ cat(
Karsten Hopp b97b9a
*** ../vim-7.4.635/src/version.c	2015-02-17 14:15:13.005523167 +0100
Karsten Hopp b97b9a
--- src/version.c	2015-02-17 15:32:53.024986843 +0100
Karsten Hopp b97b9a
***************
Karsten Hopp b97b9a
*** 743,744 ****
Karsten Hopp b97b9a
--- 743,746 ----
Karsten Hopp b97b9a
  {   /* Add new patch number below this line */
Karsten Hopp b97b9a
+ /**/
Karsten Hopp b97b9a
+     636,
Karsten Hopp b97b9a
  /**/
Karsten Hopp b97b9a
Karsten Hopp b97b9a
-- 
Karsten Hopp b97b9a
Marriage isn't a word.  It's a sentence.
Karsten Hopp b97b9a
Karsten Hopp b97b9a
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp b97b9a
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp b97b9a
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp b97b9a
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///