summaryrefslogtreecommitdiffstats
path: root/source/ap/vim/patches/7.3.239
blob: 1c03da3f6b547f9ba16d775310d74371afa08b76 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
To: vim_dev@googlegroups.com
Subject: Patch 7.3.239
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.3.239
Problem:    Python corrects the cursor column without taking 'virtualedit'
	    into account. (lilydjwg)
Solution:   Call check_cursor_col_win().
Files:	    src/if_py_both.h, src/mbyte.c, src/misc2.c, src/normal.c,
	    src/proto/mbyte.pro, src/proto/misc2.pro


*** ../vim-7.3.238/src/if_py_both.h	2011-06-26 04:01:37.000000000 +0200
--- src/if_py_both.h	2011-07-07 14:28:19.000000000 +0200
***************
*** 534,540 ****
      {
  	long lnum;
  	long col;
- 	long len;
  
  	if (!PyArg_Parse(val, "(ll)", &lnum, &col))
  	    return -1;
--- 534,539 ----
***************
*** 549,566 ****
  	if (VimErrorCheck())
  	    return -1;
  
- 	/* When column is out of range silently correct it. */
- 	len = (long)STRLEN(ml_get_buf(this->win->w_buffer, lnum, FALSE));
- 	if (col > len)
- 	    col = len;
- 
  	this->win->w_cursor.lnum = lnum;
  	this->win->w_cursor.col = col;
  #ifdef FEAT_VIRTUALEDIT
  	this->win->w_cursor.coladd = 0;
  #endif
! 	update_screen(VALID);
  
  	return 0;
      }
      else if (strcmp(name, "height") == 0)
--- 548,562 ----
  	if (VimErrorCheck())
  	    return -1;
  
  	this->win->w_cursor.lnum = lnum;
  	this->win->w_cursor.col = col;
  #ifdef FEAT_VIRTUALEDIT
  	this->win->w_cursor.coladd = 0;
  #endif
! 	/* When column is out of range silently correct it. */
! 	check_cursor_col_win(this->win);
  
+ 	update_screen(VALID);
  	return 0;
      }
      else if (strcmp(name, "height") == 0)
*** ../vim-7.3.238/src/mbyte.c	2011-04-11 14:29:13.000000000 +0200
--- src/mbyte.c	2011-07-07 14:27:07.000000000 +0200
***************
*** 3563,3569 ****
      void
  mb_adjust_cursor()
  {
!     mb_adjustpos(&curwin->w_cursor);
  }
  
  /*
--- 3563,3569 ----
      void
  mb_adjust_cursor()
  {
!     mb_adjustpos(curbuf, &curwin->w_cursor);
  }
  
  /*
***************
*** 3571,3577 ****
   * If it points to a tail byte it's moved backwards to the head byte.
   */
      void
! mb_adjustpos(lp)
      pos_T	*lp;
  {
      char_u	*p;
--- 3571,3578 ----
   * If it points to a tail byte it's moved backwards to the head byte.
   */
      void
! mb_adjustpos(buf, lp)
!     buf_T	*buf;
      pos_T	*lp;
  {
      char_u	*p;
***************
*** 3582,3588 ****
  #endif
  	    )
      {
! 	p = ml_get(lp->lnum);
  	lp->col -= (*mb_head_off)(p, p + lp->col);
  #ifdef FEAT_VIRTUALEDIT
  	/* Reset "coladd" when the cursor would be on the right half of a
--- 3583,3589 ----
  #endif
  	    )
      {
! 	p = ml_get_buf(buf, lp->lnum, FALSE);
  	lp->col -= (*mb_head_off)(p, p + lp->col);
  #ifdef FEAT_VIRTUALEDIT
  	/* Reset "coladd" when the cursor would be on the right half of a
*** ../vim-7.3.238/src/misc2.c	2011-04-11 16:56:29.000000000 +0200
--- src/misc2.c	2011-07-07 14:27:50.000000000 +0200
***************
*** 333,339 ****
  #ifdef FEAT_MBYTE
      /* prevent from moving onto a trail byte */
      if (has_mbyte)
! 	mb_adjustpos(pos);
  #endif
  
      if (col < wcol)
--- 333,339 ----
  #ifdef FEAT_MBYTE
      /* prevent from moving onto a trail byte */
      if (has_mbyte)
! 	mb_adjustpos(curbuf, pos);
  #endif
  
      if (col < wcol)
***************
*** 544,559 ****
      void
  check_cursor_col()
  {
      colnr_T len;
  #ifdef FEAT_VIRTUALEDIT
!     colnr_T oldcol = curwin->w_cursor.col;
!     colnr_T oldcoladd = curwin->w_cursor.col + curwin->w_cursor.coladd;
  #endif
  
!     len = (colnr_T)STRLEN(ml_get_curline());
      if (len == 0)
! 	curwin->w_cursor.col = 0;
!     else if (curwin->w_cursor.col >= len)
      {
  	/* Allow cursor past end-of-line when:
  	 * - in Insert mode or restarting Insert mode
--- 544,569 ----
      void
  check_cursor_col()
  {
+     check_cursor_col_win(curwin);
+ }
+ 
+ /*
+  * Make sure win->w_cursor.col is valid.
+  */
+     void
+ check_cursor_col_win(win)
+     win_T *win;
+ {
      colnr_T len;
  #ifdef FEAT_VIRTUALEDIT
!     colnr_T oldcol = win->w_cursor.col;
!     colnr_T oldcoladd = win->w_cursor.col + win->w_cursor.coladd;
  #endif
  
!     len = (colnr_T)STRLEN(ml_get_buf(win->w_buffer, win->w_cursor.lnum, FALSE));
      if (len == 0)
! 	win->w_cursor.col = 0;
!     else if (win->w_cursor.col >= len)
      {
  	/* Allow cursor past end-of-line when:
  	 * - in Insert mode or restarting Insert mode
***************
*** 567,599 ****
  		|| (ve_flags & VE_ONEMORE)
  #endif
  		|| virtual_active())
! 	    curwin->w_cursor.col = len;
  	else
  	{
! 	    curwin->w_cursor.col = len - 1;
  #ifdef FEAT_MBYTE
! 	    /* prevent cursor from moving on the trail byte */
  	    if (has_mbyte)
! 		mb_adjust_cursor();
  #endif
  	}
      }
!     else if (curwin->w_cursor.col < 0)
! 	curwin->w_cursor.col = 0;
  
  #ifdef FEAT_VIRTUALEDIT
      /* If virtual editing is on, we can leave the cursor on the old position,
       * only we must set it to virtual.  But don't do it when at the end of the
       * line. */
      if (oldcol == MAXCOL)
! 	curwin->w_cursor.coladd = 0;
      else if (ve_flags == VE_ALL)
      {
! 	if (oldcoladd > curwin->w_cursor.col)
! 	    curwin->w_cursor.coladd = oldcoladd - curwin->w_cursor.col;
  	else
  	    /* avoid weird number when there is a miscalculation or overflow */
! 	    curwin->w_cursor.coladd = 0;
      }
  #endif
  }
--- 577,609 ----
  		|| (ve_flags & VE_ONEMORE)
  #endif
  		|| virtual_active())
! 	    win->w_cursor.col = len;
  	else
  	{
! 	    win->w_cursor.col = len - 1;
  #ifdef FEAT_MBYTE
! 	    /* Move the cursor to the head byte. */
  	    if (has_mbyte)
! 		mb_adjustpos(win->w_buffer, &win->w_cursor);
  #endif
  	}
      }
!     else if (win->w_cursor.col < 0)
! 	win->w_cursor.col = 0;
  
  #ifdef FEAT_VIRTUALEDIT
      /* If virtual editing is on, we can leave the cursor on the old position,
       * only we must set it to virtual.  But don't do it when at the end of the
       * line. */
      if (oldcol == MAXCOL)
! 	win->w_cursor.coladd = 0;
      else if (ve_flags == VE_ALL)
      {
! 	if (oldcoladd > win->w_cursor.col)
! 	    win->w_cursor.coladd = oldcoladd - win->w_cursor.col;
  	else
  	    /* avoid weird number when there is a miscalculation or overflow */
! 	    win->w_cursor.coladd = 0;
      }
  #endif
  }
*** ../vim-7.3.238/src/normal.c	2011-06-20 00:45:55.000000000 +0200
--- src/normal.c	2011-07-07 14:27:57.000000000 +0200
***************
*** 8774,8780 ****
  	{
  	    --pp->col;
  #ifdef FEAT_MBYTE
! 	    mb_adjustpos(pp);
  #endif
  	}
  	else if (pp->lnum > 1)
--- 8774,8780 ----
  	{
  	    --pp->col;
  #ifdef FEAT_MBYTE
! 	    mb_adjustpos(curbuf, pp);
  #endif
  	}
  	else if (pp->lnum > 1)
*** ../vim-7.3.238/src/proto/mbyte.pro	2010-08-15 21:57:28.000000000 +0200
--- src/proto/mbyte.pro	2011-07-07 14:27:09.000000000 +0200
***************
*** 56,62 ****
  int utf_valid_string __ARGS((char_u *s, char_u *end));
  int dbcs_screen_tail_off __ARGS((char_u *base, char_u *p));
  void mb_adjust_cursor __ARGS((void));
! void mb_adjustpos __ARGS((pos_T *lp));
  char_u *mb_prevptr __ARGS((char_u *line, char_u *p));
  int mb_charlen __ARGS((char_u *str));
  int mb_charlen_len __ARGS((char_u *str, int len));
--- 56,62 ----
  int utf_valid_string __ARGS((char_u *s, char_u *end));
  int dbcs_screen_tail_off __ARGS((char_u *base, char_u *p));
  void mb_adjust_cursor __ARGS((void));
! void mb_adjustpos __ARGS((buf_T *buf, pos_T *lp));
  char_u *mb_prevptr __ARGS((char_u *line, char_u *p));
  int mb_charlen __ARGS((char_u *str));
  int mb_charlen_len __ARGS((char_u *str, int len));
*** ../vim-7.3.238/src/proto/misc2.pro	2011-04-11 16:56:29.000000000 +0200
--- src/proto/misc2.pro	2011-07-07 14:26:57.000000000 +0200
***************
*** 14,19 ****
--- 14,20 ----
  linenr_T get_cursor_rel_lnum __ARGS((win_T *wp, linenr_T lnum));
  void check_cursor_lnum __ARGS((void));
  void check_cursor_col __ARGS((void));
+ void check_cursor_col_win __ARGS((win_T *win));
  void check_cursor __ARGS((void));
  void adjust_cursor_col __ARGS((void));
  int leftcol_changed __ARGS((void));
*** ../vim-7.3.238/src/version.c	2011-07-07 15:04:38.000000000 +0200
--- src/version.c	2011-07-07 15:05:49.000000000 +0200
***************
*** 711,712 ****
--- 711,714 ----
  {   /* Add new patch number below this line */
+ /**/
+     239,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
256. You are able to write down over 250 symptoms of being an internet
     addict, even though they only asked for 101.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///