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