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: Using "." to repeat a Visual delete counts the size in bytes, not
12 characters. (Connor Lane Smith)
13 Solution: Store the virtual column numbers instead of byte positions.
17 *** ../vim-7.3.332/src/normal.c 2011-07-15 17:51:30.000000000 +0200
18 --- src/normal.c 2011-10-04 19:47:14.000000000 +0200
22 static int resel_VIsual_mode = NUL; /* 'v', 'V', or Ctrl-V */
23 static linenr_T resel_VIsual_line_count; /* number of lines */
24 ! static colnr_T resel_VIsual_col; /* nr of cols or end col */
26 static int restart_VIsual_select = 0;
30 static int resel_VIsual_mode = NUL; /* 'v', 'V', or Ctrl-V */
31 static linenr_T resel_VIsual_line_count; /* number of lines */
32 ! static colnr_T resel_VIsual_vcol; /* nr of cols or end col */
34 static int restart_VIsual_select = 0;
38 /* The visual area is remembered for redo */
39 static int redo_VIsual_mode = NUL; /* 'v', 'V', or Ctrl-V */
40 static linenr_T redo_VIsual_line_count; /* number of lines */
41 ! static colnr_T redo_VIsual_col; /* number of cols or end column */
42 static long redo_VIsual_count; /* count for Visual operator */
43 # ifdef FEAT_VIRTUALEDIT
44 int include_line_break = FALSE;
46 /* The visual area is remembered for redo */
47 static int redo_VIsual_mode = NUL; /* 'v', 'V', or Ctrl-V */
48 static linenr_T redo_VIsual_line_count; /* number of lines */
49 ! static colnr_T redo_VIsual_vcol; /* number of cols or end column */
50 static long redo_VIsual_count; /* count for Visual operator */
51 # ifdef FEAT_VIRTUALEDIT
52 int include_line_break = FALSE;
58 oap->start = curwin->w_cursor;
59 curwin->w_cursor.lnum += redo_VIsual_line_count - 1;
60 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)
61 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
62 VIsual_mode = redo_VIsual_mode;
63 ! if (VIsual_mode == 'v')
65 ! if (redo_VIsual_line_count <= 1)
66 ! curwin->w_cursor.col += redo_VIsual_col - 1;
68 ! curwin->w_cursor.col = redo_VIsual_col;
70 ! if (redo_VIsual_col == MAXCOL)
72 ! curwin->w_curswant = MAXCOL;
73 ! coladvance((colnr_T)MAXCOL);
75 cap->count0 = redo_VIsual_count;
76 if (redo_VIsual_count != 0)
81 + /* Redo of an operation on a Visual area. Use the same size from
82 + * redo_VIsual_line_count and redo_VIsual_vcol. */
83 oap->start = curwin->w_cursor;
84 curwin->w_cursor.lnum += redo_VIsual_line_count - 1;
85 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)
86 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
87 VIsual_mode = redo_VIsual_mode;
88 ! if (redo_VIsual_vcol == MAXCOL || VIsual_mode == 'v')
90 ! if (VIsual_mode == 'v')
92 ! if (redo_VIsual_line_count <= 1)
95 ! curwin->w_curswant =
96 ! curwin->w_virtcol + redo_VIsual_vcol - 1;
99 ! curwin->w_curswant = redo_VIsual_vcol;
103 ! curwin->w_curswant = MAXCOL;
105 ! coladvance(curwin->w_curswant);
107 cap->count0 = redo_VIsual_count;
108 if (redo_VIsual_count != 0)
113 else if (redo_VIsual_busy)
114 ! oap->end_vcol = oap->start_vcol + redo_VIsual_col - 1;
116 * Correct oap->end.col and oap->start.col to be the
117 * upper-left and lower-right corner of the block area.
121 else if (redo_VIsual_busy)
122 ! oap->end_vcol = oap->start_vcol + redo_VIsual_vcol - 1;
124 * Correct oap->end.col and oap->start.col to be the
125 * upper-left and lower-right corner of the block area.
129 resel_VIsual_mode = VIsual_mode;
130 if (curwin->w_curswant == MAXCOL)
131 ! resel_VIsual_col = MAXCOL;
132 ! else if (VIsual_mode == Ctrl_V)
133 ! resel_VIsual_col = oap->end_vcol - oap->start_vcol + 1;
134 ! else if (oap->line_count > 1)
135 ! resel_VIsual_col = oap->end.col;
137 ! resel_VIsual_col = oap->end.col - oap->start.col + 1;
138 resel_VIsual_line_count = oap->line_count;
143 resel_VIsual_mode = VIsual_mode;
144 if (curwin->w_curswant == MAXCOL)
145 ! resel_VIsual_vcol = MAXCOL;
148 ! if (VIsual_mode != Ctrl_V)
149 ! getvvcol(curwin, &(oap->end),
150 ! NULL, NULL, &oap->end_vcol);
151 ! if (VIsual_mode == Ctrl_V || oap->line_count <= 1)
153 ! if (VIsual_mode != Ctrl_V)
154 ! getvvcol(curwin, &(oap->start),
155 ! &oap->start_vcol, NULL, NULL);
156 ! resel_VIsual_vcol = oap->end_vcol - oap->start_vcol + 1;
159 ! resel_VIsual_vcol = oap->end_vcol;
161 resel_VIsual_line_count = oap->line_count;
166 if (!redo_VIsual_busy)
168 redo_VIsual_mode = resel_VIsual_mode;
169 ! redo_VIsual_col = resel_VIsual_col;
170 redo_VIsual_line_count = resel_VIsual_line_count;
171 redo_VIsual_count = cap->count0;
174 if (!redo_VIsual_busy)
176 redo_VIsual_mode = resel_VIsual_mode;
177 ! redo_VIsual_vcol = resel_VIsual_vcol;
178 redo_VIsual_line_count = resel_VIsual_line_count;
179 redo_VIsual_count = cap->count0;
183 if (VIsual_mode == 'v')
185 if (resel_VIsual_line_count <= 1)
186 ! curwin->w_cursor.col += resel_VIsual_col * cap->count0 - 1;
188 ! curwin->w_cursor.col = resel_VIsual_col;
189 ! check_cursor_col();
191 ! if (resel_VIsual_col == MAXCOL)
193 curwin->w_curswant = MAXCOL;
194 coladvance((colnr_T)MAXCOL);
196 if (VIsual_mode == 'v')
198 if (resel_VIsual_line_count <= 1)
200 ! validate_virtcol();
201 ! curwin->w_curswant = curwin->w_virtcol
202 ! + resel_VIsual_vcol * cap->count0 - 1;
205 ! curwin->w_curswant = resel_VIsual_vcol;
206 ! coladvance(curwin->w_curswant);
208 ! if (resel_VIsual_vcol == MAXCOL)
210 curwin->w_curswant = MAXCOL;
211 coladvance((colnr_T)MAXCOL);
216 curwin->w_curswant = curwin->w_virtcol
217 ! + resel_VIsual_col * cap->count0 - 1;
218 coladvance(curwin->w_curswant);
224 curwin->w_curswant = curwin->w_virtcol
225 ! + resel_VIsual_vcol * cap->count0 - 1;
226 coladvance(curwin->w_curswant);
229 *** ../vim-7.3.332/src/version.c 2011-10-04 18:03:43.000000000 +0200
230 --- src/version.c 2011-10-04 21:05:44.000000000 +0200
234 { /* Add new patch number below this line */
240 It was recently discovered that research causes cancer in rats.
242 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
243 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
244 \\\ an exciting new programming language -- http://www.Zimbu.org ///
245 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///