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