Karsten Hopp bf88f0
To: vim_dev@googlegroups.com
Karsten Hopp bf88f0
Subject: Patch 7.3.086
Karsten Hopp bf88f0
Fcc: outbox
Karsten Hopp bf88f0
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp bf88f0
Mime-Version: 1.0
Karsten Hopp bf88f0
Content-Type: text/plain; charset=UTF-8
Karsten Hopp bf88f0
Content-Transfer-Encoding: 8bit
Karsten Hopp bf88f0
------------
Karsten Hopp bf88f0
Karsten Hopp bf88f0
Patch 7.3.086
Karsten Hopp bf88f0
Problem:    When using a mapping with an expression and there was no count,
Karsten Hopp bf88f0
	    v:count has the value of the previous command. (ZyX)
Karsten Hopp bf88f0
Solution:   Also set v:count and v:count1 before getting the character that
Karsten Hopp bf88f0
	    could be a command or a count.
Karsten Hopp bf88f0
Files:	    src/normal.c
Karsten Hopp bf88f0
Karsten Hopp bf88f0
Karsten Hopp bf88f0
*** ../vim-7.3.085/src/normal.c	2010-10-13 18:06:42.000000000 +0200
Karsten Hopp bf88f0
--- src/normal.c	2010-12-17 18:46:56.000000000 +0100
Karsten Hopp bf88f0
***************
Karsten Hopp bf88f0
*** 25,30 ****
Karsten Hopp bf88f0
--- 25,33 ----
Karsten Hopp bf88f0
  static int	restart_VIsual_select = 0;
Karsten Hopp bf88f0
  #endif
Karsten Hopp bf88f0
  
Karsten Hopp bf88f0
+ #ifdef FEAT_EVAL
Karsten Hopp bf88f0
+ static void	set_vcount_ca __ARGS((cmdarg_T *cap, int *set_prevcount));
Karsten Hopp bf88f0
+ #endif
Karsten Hopp bf88f0
  static int
Karsten Hopp bf88f0
  # ifdef __BORLANDC__
Karsten Hopp bf88f0
  _RTLENTRYF
Karsten Hopp bf88f0
***************
Karsten Hopp bf88f0
*** 648,653 ****
Karsten Hopp bf88f0
--- 651,664 ----
Karsten Hopp bf88f0
      dont_scroll = FALSE;	/* allow scrolling here */
Karsten Hopp bf88f0
  #endif
Karsten Hopp bf88f0
  
Karsten Hopp bf88f0
+ #ifdef FEAT_EVAL
Karsten Hopp bf88f0
+     /* Set v:count here, when called from main() and not a stuffed
Karsten Hopp bf88f0
+      * command, so that v:count can be used in an expression mapping
Karsten Hopp bf88f0
+      * when there is no count. */
Karsten Hopp bf88f0
+     if (toplevel && stuff_empty())
Karsten Hopp bf88f0
+ 	set_vcount_ca(&ca, &set_prevcount);
Karsten Hopp bf88f0
+ #endif
Karsten Hopp bf88f0
+ 
Karsten Hopp bf88f0
      /*
Karsten Hopp bf88f0
       * Get the command character from the user.
Karsten Hopp bf88f0
       */
Karsten Hopp bf88f0
***************
Karsten Hopp bf88f0
*** 725,739 ****
Karsten Hopp bf88f0
  	     * command, so that v:count can be used in an expression mapping
Karsten Hopp bf88f0
  	     * right after the count. */
Karsten Hopp bf88f0
  	    if (toplevel && stuff_empty())
Karsten Hopp bf88f0
! 	    {
Karsten Hopp bf88f0
! 		long count = ca.count0;
Karsten Hopp bf88f0
! 
Karsten Hopp bf88f0
! 		/* multiply with ca.opcount the same way as below */
Karsten Hopp bf88f0
! 		if (ca.opcount != 0)
Karsten Hopp bf88f0
! 		    count = ca.opcount * (count == 0 ? 1 : count);
Karsten Hopp bf88f0
! 		set_vcount(count, count == 0 ? 1 : count, set_prevcount);
Karsten Hopp bf88f0
! 		set_prevcount = FALSE;  /* only set v:prevcount once */
Karsten Hopp bf88f0
! 	    }
Karsten Hopp bf88f0
  #endif
Karsten Hopp bf88f0
  	    if (ctrl_w)
Karsten Hopp bf88f0
  	    {
Karsten Hopp bf88f0
--- 736,742 ----
Karsten Hopp bf88f0
  	     * command, so that v:count can be used in an expression mapping
Karsten Hopp bf88f0
  	     * right after the count. */
Karsten Hopp bf88f0
  	    if (toplevel && stuff_empty())
Karsten Hopp bf88f0
! 		set_vcount_ca(&ca, &set_prevcount);
Karsten Hopp bf88f0
  #endif
Karsten Hopp bf88f0
  	    if (ctrl_w)
Karsten Hopp bf88f0
  	    {
Karsten Hopp bf88f0
***************
Karsten Hopp bf88f0
*** 1386,1391 ****
Karsten Hopp bf88f0
--- 1389,1414 ----
Karsten Hopp bf88f0
      opcount = ca.opcount;
Karsten Hopp bf88f0
  }
Karsten Hopp bf88f0
  
Karsten Hopp bf88f0
+ #ifdef FEAT_EVAL
Karsten Hopp bf88f0
+ /*
Karsten Hopp bf88f0
+  * Set v:count and v:count1 according to "cap".
Karsten Hopp bf88f0
+  * Set v:prevcount only when "set_prevcount" is TRUE.
Karsten Hopp bf88f0
+  */
Karsten Hopp bf88f0
+     static void
Karsten Hopp bf88f0
+ set_vcount_ca(cap, set_prevcount)
Karsten Hopp bf88f0
+     cmdarg_T	*cap;
Karsten Hopp bf88f0
+     int		*set_prevcount;
Karsten Hopp bf88f0
+ {
Karsten Hopp bf88f0
+     long count = cap->count0;
Karsten Hopp bf88f0
+ 
Karsten Hopp bf88f0
+     /* multiply with cap->opcount the same way as above */
Karsten Hopp bf88f0
+     if (cap->opcount != 0)
Karsten Hopp bf88f0
+ 	count = cap->opcount * (count == 0 ? 1 : count);
Karsten Hopp bf88f0
+     set_vcount(count, count == 0 ? 1 : count, *set_prevcount);
Karsten Hopp bf88f0
+     *set_prevcount = FALSE;  /* only set v:prevcount once */
Karsten Hopp bf88f0
+ }
Karsten Hopp bf88f0
+ #endif
Karsten Hopp bf88f0
+ 
Karsten Hopp bf88f0
  /*
Karsten Hopp bf88f0
   * Handle an operator after visual mode or when the movement is finished
Karsten Hopp bf88f0
   */
Karsten Hopp bf88f0
***************
Karsten Hopp bf88f0
*** 8529,8535 ****
Karsten Hopp bf88f0
      else
Karsten Hopp bf88f0
  	curwin->w_curswant = 0;
Karsten Hopp bf88f0
      /* keep curswant at the column where we wanted to go, not where
Karsten Hopp bf88f0
!        we ended; differs if line is too short */
Karsten Hopp bf88f0
      curwin->w_set_curswant = FALSE;
Karsten Hopp bf88f0
  }
Karsten Hopp bf88f0
  
Karsten Hopp bf88f0
--- 8552,8558 ----
Karsten Hopp bf88f0
      else
Karsten Hopp bf88f0
  	curwin->w_curswant = 0;
Karsten Hopp bf88f0
      /* keep curswant at the column where we wanted to go, not where
Karsten Hopp bf88f0
!      * we ended; differs if line is too short */
Karsten Hopp bf88f0
      curwin->w_set_curswant = FALSE;
Karsten Hopp bf88f0
  }
Karsten Hopp bf88f0
  
Karsten Hopp bf88f0
*** ../vim-7.3.085/src/version.c	2010-12-17 18:06:00.000000000 +0100
Karsten Hopp bf88f0
--- src/version.c	2010-12-17 18:51:20.000000000 +0100
Karsten Hopp bf88f0
***************
Karsten Hopp bf88f0
*** 716,717 ****
Karsten Hopp bf88f0
--- 716,719 ----
Karsten Hopp bf88f0
  {   /* Add new patch number below this line */
Karsten Hopp bf88f0
+ /**/
Karsten Hopp bf88f0
+     86,
Karsten Hopp bf88f0
  /**/
Karsten Hopp bf88f0
Karsten Hopp bf88f0
-- 
Karsten Hopp bf88f0
How To Keep A Healthy Level Of Insanity:
Karsten Hopp bf88f0
15. Five days in advance, tell your friends you can't attend their
Karsten Hopp bf88f0
    party because you're not in the mood.
Karsten Hopp bf88f0
Karsten Hopp bf88f0
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp bf88f0
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp bf88f0
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp bf88f0
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///