1 To: vim_dev@googlegroups.com
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: When using a mapping with an expression and there was no count,
12 v:count has the value of the previous command. (ZyX)
13 Solution: Also set v:count and v:count1 before getting the character that
14 could be a command or a count.
18 *** ../vim-7.3.085/src/normal.c 2010-10-13 18:06:42.000000000 +0200
19 --- src/normal.c 2010-12-17 18:46:56.000000000 +0100
23 static int restart_VIsual_select = 0;
27 + static void set_vcount_ca __ARGS((cmdarg_T *cap, int *set_prevcount));
35 dont_scroll = FALSE; /* allow scrolling here */
39 + /* Set v:count here, when called from main() and not a stuffed
40 + * command, so that v:count can be used in an expression mapping
41 + * when there is no count. */
42 + if (toplevel && stuff_empty())
43 + set_vcount_ca(&ca, &set_prevcount);
47 * Get the command character from the user.
51 * command, so that v:count can be used in an expression mapping
52 * right after the count. */
53 if (toplevel && stuff_empty())
55 ! long count = ca.count0;
57 ! /* multiply with ca.opcount the same way as below */
58 ! if (ca.opcount != 0)
59 ! count = ca.opcount * (count == 0 ? 1 : count);
60 ! set_vcount(count, count == 0 ? 1 : count, set_prevcount);
61 ! set_prevcount = FALSE; /* only set v:prevcount once */
67 * command, so that v:count can be used in an expression mapping
68 * right after the count. */
69 if (toplevel && stuff_empty())
70 ! set_vcount_ca(&ca, &set_prevcount);
82 + * Set v:count and v:count1 according to "cap".
83 + * Set v:prevcount only when "set_prevcount" is TRUE.
86 + set_vcount_ca(cap, set_prevcount)
90 + long count = cap->count0;
92 + /* multiply with cap->opcount the same way as above */
93 + if (cap->opcount != 0)
94 + count = cap->opcount * (count == 0 ? 1 : count);
95 + set_vcount(count, count == 0 ? 1 : count, *set_prevcount);
96 + *set_prevcount = FALSE; /* only set v:prevcount once */
101 * Handle an operator after visual mode or when the movement is finished
106 curwin->w_curswant = 0;
107 /* keep curswant at the column where we wanted to go, not where
108 ! we ended; differs if line is too short */
109 curwin->w_set_curswant = FALSE;
114 curwin->w_curswant = 0;
115 /* keep curswant at the column where we wanted to go, not where
116 ! * we ended; differs if line is too short */
117 curwin->w_set_curswant = FALSE;
120 *** ../vim-7.3.085/src/version.c 2010-12-17 18:06:00.000000000 +0100
121 --- src/version.c 2010-12-17 18:51:20.000000000 +0100
125 { /* Add new patch number below this line */
131 How To Keep A Healthy Level Of Insanity:
132 15. Five days in advance, tell your friends you can't attend their
133 party because you're not in the mood.
135 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
136 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
137 \\\ an exciting new programming language -- http://www.Zimbu.org ///
138 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///