e688175
To: vim-dev@vim.org
e688175
Subject: Patch 7.2.048
e688175
Fcc: outbox
e688175
From: Bram Moolenaar <Bram@moolenaar.net>
e688175
Mime-Version: 1.0
e688175
Content-Type: text/plain; charset=ISO-8859-1
e688175
Content-Transfer-Encoding: 8bit
e688175
------------
e688175
e688175
Patch 7.2.048
e688175
Problem:    v:prevcount is changed too often.  Counts are not multiplied when
e688175
	    setting v:count.
e688175
Solution:   Set v:prevcount properly.  Multiply counts. (idea by Ben Schmidt)
e688175
Files:	    src/eval.c, src/normal.c, src/proto/eval.pro
e688175
e688175
e688175
*** ../vim-7.2.047/src/eval.c	Thu Nov 20 10:36:04 2008
e688175
--- src/eval.c	Thu Nov 20 15:53:47 2008
e688175
***************
e688175
*** 18146,18159 ****
e688175
  }
e688175
  
e688175
  /*
e688175
!  * Set v:count, v:count1 and v:prevcount.
e688175
   */
e688175
      void
e688175
! set_vcount(count, count1)
e688175
      long	count;
e688175
      long	count1;
e688175
  {
e688175
!     vimvars[VV_PREVCOUNT].vv_nr = vimvars[VV_COUNT].vv_nr;
e688175
      vimvars[VV_COUNT].vv_nr = count;
e688175
      vimvars[VV_COUNT1].vv_nr = count1;
e688175
  }
e688175
--- 18146,18162 ----
e688175
  }
e688175
  
e688175
  /*
e688175
!  * Set v:count to "count" and v:count1 to "count1".
e688175
!  * When "set_prevcount" is TRUE first set v:prevcount from v:count.
e688175
   */
e688175
      void
e688175
! set_vcount(count, count1, set_prevcount)
e688175
      long	count;
e688175
      long	count1;
e688175
+     int		set_prevcount;
e688175
  {
e688175
!     if (set_prevcount)
e688175
! 	vimvars[VV_PREVCOUNT].vv_nr = vimvars[VV_COUNT].vv_nr;
e688175
      vimvars[VV_COUNT].vv_nr = count;
e688175
      vimvars[VV_COUNT1].vv_nr = count1;
e688175
  }
e688175
*** ../vim-7.2.047/src/normal.c	Sat Nov 15 14:10:23 2008
e688175
--- src/normal.c	Thu Nov 20 16:04:44 2008
e688175
***************
e688175
*** 580,585 ****
e688175
--- 580,588 ----
e688175
      static int	old_mapped_len = 0;
e688175
  #endif
e688175
      int		idx;
e688175
+ #ifdef FEAT_EVAL
e688175
+     int		set_prevcount = FALSE;
e688175
+ #endif
e688175
  
e688175
      vim_memset(&ca, 0, sizeof(ca));	/* also resets ca.retval */
e688175
      ca.oap = oap;
e688175
***************
e688175
*** 615,621 ****
e688175
--- 618,629 ----
e688175
      /* When not finishing an operator and no register name typed, reset the
e688175
       * count. */
e688175
      if (!finish_op && !oap->regname)
e688175
+     {
e688175
  	ca.opcount = 0;
e688175
+ #ifdef FEAT_EVAL
e688175
+ 	set_prevcount = TRUE;
e688175
+ #endif
e688175
+     }
e688175
  
e688175
  #ifdef FEAT_AUTOCMD
e688175
      /* Restore counts from before receiving K_CURSORHOLD.  This means after
e688175
***************
e688175
*** 719,725 ****
e688175
  	     * command, so that v:count can be used in an expression mapping
e688175
  	     * right after the count. */
e688175
  	    if (toplevel && stuff_empty())
e688175
! 		set_vcount(ca.count0, ca.count0 == 0 ? 1 : ca.count0);
e688175
  #endif
e688175
  	    if (ctrl_w)
e688175
  	    {
e688175
--- 727,741 ----
e688175
  	     * command, so that v:count can be used in an expression mapping
e688175
  	     * right after the count. */
e688175
  	    if (toplevel && stuff_empty())
e688175
! 	    {
e688175
! 		long count = ca.count0;
e688175
! 
e688175
! 		/* multiply with ca.opcount the same way as below */
e688175
! 		if (ca.opcount != 0)
e688175
! 		    count = ca.opcount * (count == 0 ? 1 : count);
e688175
! 		set_vcount(count, count == 0 ? 1 : count, set_prevcount);
e688175
! 		set_prevcount = FALSE;  /* only set v:prevcount once */
e688175
! 	    }
e688175
  #endif
e688175
  	    if (ctrl_w)
e688175
  	    {
e688175
***************
e688175
*** 806,812 ****
e688175
       * Only set v:count when called from main() and not a stuffed command.
e688175
       */
e688175
      if (toplevel && stuff_empty())
e688175
! 	set_vcount(ca.count0, ca.count1);
e688175
  #endif
e688175
  
e688175
      /*
e688175
--- 822,828 ----
e688175
       * Only set v:count when called from main() and not a stuffed command.
e688175
       */
e688175
      if (toplevel && stuff_empty())
e688175
! 	set_vcount(ca.count0, ca.count1, set_prevcount);
e688175
  #endif
e688175
  
e688175
      /*
e688175
*** ../vim-7.2.047/src/proto/eval.pro	Sun Nov  9 13:43:25 2008
e688175
--- src/proto/eval.pro	Thu Nov 20 15:53:54 2008
e688175
***************
e688175
*** 61,67 ****
e688175
  long get_vim_var_nr __ARGS((int idx));
e688175
  char_u *get_vim_var_str __ARGS((int idx));
e688175
  list_T *get_vim_var_list __ARGS((int idx));
e688175
! void set_vcount __ARGS((long count, long count1));
e688175
  void set_vim_var_string __ARGS((int idx, char_u *val, int len));
e688175
  void set_vim_var_list __ARGS((int idx, list_T *val));
e688175
  void set_reg_var __ARGS((int c));
e688175
--- 61,67 ----
e688175
  long get_vim_var_nr __ARGS((int idx));
e688175
  char_u *get_vim_var_str __ARGS((int idx));
e688175
  list_T *get_vim_var_list __ARGS((int idx));
e688175
! void set_vcount __ARGS((long count, long count1, int set_prevcount));
e688175
  void set_vim_var_string __ARGS((int idx, char_u *val, int len));
e688175
  void set_vim_var_list __ARGS((int idx, list_T *val));
e688175
  void set_reg_var __ARGS((int c));
e688175
*** ../vim-7.2.047/src/version.c	Thu Nov 20 14:11:47 2008
e688175
--- src/version.c	Thu Nov 20 16:08:19 2008
e688175
***************
e688175
*** 678,679 ****
e688175
--- 678,681 ----
e688175
  {   /* Add new patch number below this line */
e688175
+ /**/
e688175
+     48,
e688175
  /**/
e688175
e688175
-- 
e688175
Microsoft's definition of a boolean: TRUE, FALSE, MAYBE
e688175
"Embrace and extend"...?
e688175
e688175
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
e688175
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
e688175
\\\        download, build and distribute -- http://www.A-A-P.org        ///
e688175
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///