]> git.pld-linux.org Git - packages/vim.git/blame - 7.3.239
- new
[packages/vim.git] / 7.3.239
CommitLineData
a2e11672
AG
1To: vim_dev@googlegroups.com
2Subject: Patch 7.3.239
3Fcc: outbox
4From: Bram Moolenaar <Bram@moolenaar.net>
5Mime-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8------------
9
10Patch 7.3.239
11Problem: Python corrects the cursor column without taking 'virtualedit'
12 into account. (lilydjwg)
13Solution: Call check_cursor_col_win().
14Files: src/if_py_both.h, src/mbyte.c, src/misc2.c, src/normal.c,
15 src/proto/mbyte.pro, src/proto/misc2.pro
16
17
18*** ../vim-7.3.238/src/if_py_both.h 2011-06-26 04:01:37.000000000 +0200
19--- src/if_py_both.h 2011-07-07 14:28:19.000000000 +0200
20***************
21*** 534,540 ****
22 {
23 long lnum;
24 long col;
25- long len;
26
27 if (!PyArg_Parse(val, "(ll)", &lnum, &col))
28 return -1;
29--- 534,539 ----
30***************
31*** 549,566 ****
32 if (VimErrorCheck())
33 return -1;
34
35- /* When column is out of range silently correct it. */
36- len = (long)STRLEN(ml_get_buf(this->win->w_buffer, lnum, FALSE));
37- if (col > len)
38- col = len;
39-
40 this->win->w_cursor.lnum = lnum;
41 this->win->w_cursor.col = col;
42 #ifdef FEAT_VIRTUALEDIT
43 this->win->w_cursor.coladd = 0;
44 #endif
45! update_screen(VALID);
46
47 return 0;
48 }
49 else if (strcmp(name, "height") == 0)
50--- 548,562 ----
51 if (VimErrorCheck())
52 return -1;
53
54 this->win->w_cursor.lnum = lnum;
55 this->win->w_cursor.col = col;
56 #ifdef FEAT_VIRTUALEDIT
57 this->win->w_cursor.coladd = 0;
58 #endif
59! /* When column is out of range silently correct it. */
60! check_cursor_col_win(this->win);
61
62+ update_screen(VALID);
63 return 0;
64 }
65 else if (strcmp(name, "height") == 0)
66*** ../vim-7.3.238/src/mbyte.c 2011-04-11 14:29:13.000000000 +0200
67--- src/mbyte.c 2011-07-07 14:27:07.000000000 +0200
68***************
69*** 3563,3569 ****
70 void
71 mb_adjust_cursor()
72 {
73! mb_adjustpos(&curwin->w_cursor);
74 }
75
76 /*
77--- 3563,3569 ----
78 void
79 mb_adjust_cursor()
80 {
81! mb_adjustpos(curbuf, &curwin->w_cursor);
82 }
83
84 /*
85***************
86*** 3571,3577 ****
87 * If it points to a tail byte it's moved backwards to the head byte.
88 */
89 void
90! mb_adjustpos(lp)
91 pos_T *lp;
92 {
93 char_u *p;
94--- 3571,3578 ----
95 * If it points to a tail byte it's moved backwards to the head byte.
96 */
97 void
98! mb_adjustpos(buf, lp)
99! buf_T *buf;
100 pos_T *lp;
101 {
102 char_u *p;
103***************
104*** 3582,3588 ****
105 #endif
106 )
107 {
108! p = ml_get(lp->lnum);
109 lp->col -= (*mb_head_off)(p, p + lp->col);
110 #ifdef FEAT_VIRTUALEDIT
111 /* Reset "coladd" when the cursor would be on the right half of a
112--- 3583,3589 ----
113 #endif
114 )
115 {
116! p = ml_get_buf(buf, lp->lnum, FALSE);
117 lp->col -= (*mb_head_off)(p, p + lp->col);
118 #ifdef FEAT_VIRTUALEDIT
119 /* Reset "coladd" when the cursor would be on the right half of a
120*** ../vim-7.3.238/src/misc2.c 2011-04-11 16:56:29.000000000 +0200
121--- src/misc2.c 2011-07-07 14:27:50.000000000 +0200
122***************
123*** 333,339 ****
124 #ifdef FEAT_MBYTE
125 /* prevent from moving onto a trail byte */
126 if (has_mbyte)
127! mb_adjustpos(pos);
128 #endif
129
130 if (col < wcol)
131--- 333,339 ----
132 #ifdef FEAT_MBYTE
133 /* prevent from moving onto a trail byte */
134 if (has_mbyte)
135! mb_adjustpos(curbuf, pos);
136 #endif
137
138 if (col < wcol)
139***************
140*** 544,559 ****
141 void
142 check_cursor_col()
143 {
144 colnr_T len;
145 #ifdef FEAT_VIRTUALEDIT
146! colnr_T oldcol = curwin->w_cursor.col;
147! colnr_T oldcoladd = curwin->w_cursor.col + curwin->w_cursor.coladd;
148 #endif
149
150! len = (colnr_T)STRLEN(ml_get_curline());
151 if (len == 0)
152! curwin->w_cursor.col = 0;
153! else if (curwin->w_cursor.col >= len)
154 {
155 /* Allow cursor past end-of-line when:
156 * - in Insert mode or restarting Insert mode
157--- 544,569 ----
158 void
159 check_cursor_col()
160 {
161+ check_cursor_col_win(curwin);
162+ }
163+
164+ /*
165+ * Make sure win->w_cursor.col is valid.
166+ */
167+ void
168+ check_cursor_col_win(win)
169+ win_T *win;
170+ {
171 colnr_T len;
172 #ifdef FEAT_VIRTUALEDIT
173! colnr_T oldcol = win->w_cursor.col;
174! colnr_T oldcoladd = win->w_cursor.col + win->w_cursor.coladd;
175 #endif
176
177! len = (colnr_T)STRLEN(ml_get_buf(win->w_buffer, win->w_cursor.lnum, FALSE));
178 if (len == 0)
179! win->w_cursor.col = 0;
180! else if (win->w_cursor.col >= len)
181 {
182 /* Allow cursor past end-of-line when:
183 * - in Insert mode or restarting Insert mode
184***************
185*** 567,599 ****
186 || (ve_flags & VE_ONEMORE)
187 #endif
188 || virtual_active())
189! curwin->w_cursor.col = len;
190 else
191 {
192! curwin->w_cursor.col = len - 1;
193 #ifdef FEAT_MBYTE
194! /* prevent cursor from moving on the trail byte */
195 if (has_mbyte)
196! mb_adjust_cursor();
197 #endif
198 }
199 }
200! else if (curwin->w_cursor.col < 0)
201! curwin->w_cursor.col = 0;
202
203 #ifdef FEAT_VIRTUALEDIT
204 /* If virtual editing is on, we can leave the cursor on the old position,
205 * only we must set it to virtual. But don't do it when at the end of the
206 * line. */
207 if (oldcol == MAXCOL)
208! curwin->w_cursor.coladd = 0;
209 else if (ve_flags == VE_ALL)
210 {
211! if (oldcoladd > curwin->w_cursor.col)
212! curwin->w_cursor.coladd = oldcoladd - curwin->w_cursor.col;
213 else
214 /* avoid weird number when there is a miscalculation or overflow */
215! curwin->w_cursor.coladd = 0;
216 }
217 #endif
218 }
219--- 577,609 ----
220 || (ve_flags & VE_ONEMORE)
221 #endif
222 || virtual_active())
223! win->w_cursor.col = len;
224 else
225 {
226! win->w_cursor.col = len - 1;
227 #ifdef FEAT_MBYTE
228! /* Move the cursor to the head byte. */
229 if (has_mbyte)
230! mb_adjustpos(win->w_buffer, &win->w_cursor);
231 #endif
232 }
233 }
234! else if (win->w_cursor.col < 0)
235! win->w_cursor.col = 0;
236
237 #ifdef FEAT_VIRTUALEDIT
238 /* If virtual editing is on, we can leave the cursor on the old position,
239 * only we must set it to virtual. But don't do it when at the end of the
240 * line. */
241 if (oldcol == MAXCOL)
242! win->w_cursor.coladd = 0;
243 else if (ve_flags == VE_ALL)
244 {
245! if (oldcoladd > win->w_cursor.col)
246! win->w_cursor.coladd = oldcoladd - win->w_cursor.col;
247 else
248 /* avoid weird number when there is a miscalculation or overflow */
249! win->w_cursor.coladd = 0;
250 }
251 #endif
252 }
253*** ../vim-7.3.238/src/normal.c 2011-06-20 00:45:55.000000000 +0200
254--- src/normal.c 2011-07-07 14:27:57.000000000 +0200
255***************
256*** 8774,8780 ****
257 {
258 --pp->col;
259 #ifdef FEAT_MBYTE
260! mb_adjustpos(pp);
261 #endif
262 }
263 else if (pp->lnum > 1)
264--- 8774,8780 ----
265 {
266 --pp->col;
267 #ifdef FEAT_MBYTE
268! mb_adjustpos(curbuf, pp);
269 #endif
270 }
271 else if (pp->lnum > 1)
272*** ../vim-7.3.238/src/proto/mbyte.pro 2010-08-15 21:57:28.000000000 +0200
273--- src/proto/mbyte.pro 2011-07-07 14:27:09.000000000 +0200
274***************
275*** 56,62 ****
276 int utf_valid_string __ARGS((char_u *s, char_u *end));
277 int dbcs_screen_tail_off __ARGS((char_u *base, char_u *p));
278 void mb_adjust_cursor __ARGS((void));
279! void mb_adjustpos __ARGS((pos_T *lp));
280 char_u *mb_prevptr __ARGS((char_u *line, char_u *p));
281 int mb_charlen __ARGS((char_u *str));
282 int mb_charlen_len __ARGS((char_u *str, int len));
283--- 56,62 ----
284 int utf_valid_string __ARGS((char_u *s, char_u *end));
285 int dbcs_screen_tail_off __ARGS((char_u *base, char_u *p));
286 void mb_adjust_cursor __ARGS((void));
287! void mb_adjustpos __ARGS((buf_T *buf, pos_T *lp));
288 char_u *mb_prevptr __ARGS((char_u *line, char_u *p));
289 int mb_charlen __ARGS((char_u *str));
290 int mb_charlen_len __ARGS((char_u *str, int len));
291*** ../vim-7.3.238/src/proto/misc2.pro 2011-04-11 16:56:29.000000000 +0200
292--- src/proto/misc2.pro 2011-07-07 14:26:57.000000000 +0200
293***************
294*** 14,19 ****
295--- 14,20 ----
296 linenr_T get_cursor_rel_lnum __ARGS((win_T *wp, linenr_T lnum));
297 void check_cursor_lnum __ARGS((void));
298 void check_cursor_col __ARGS((void));
299+ void check_cursor_col_win __ARGS((win_T *win));
300 void check_cursor __ARGS((void));
301 void adjust_cursor_col __ARGS((void));
302 int leftcol_changed __ARGS((void));
303*** ../vim-7.3.238/src/version.c 2011-07-07 15:04:38.000000000 +0200
304--- src/version.c 2011-07-07 15:05:49.000000000 +0200
305***************
306*** 711,712 ****
307--- 711,714 ----
308 { /* Add new patch number below this line */
309+ /**/
310+ 239,
311 /**/
312
313--
314hundred-and-one symptoms of being an internet addict:
315256. You are able to write down over 250 symptoms of being an internet
316 addict, even though they only asked for 101.
317
318 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
319/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
320\\\ an exciting new programming language -- http://www.Zimbu.org ///
321 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
This page took 0.063526 seconds and 4 git commands to generate.