summaryrefslogtreecommitdiffstats
path: root/patches/source/vim/patches/7.4.310
blob: 2d25f0f2f019e0082bc430d3da916c113f8442da (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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
To: vim_dev@googlegroups.com
Subject: Patch 7.4.310
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.4.310
Problem:    getpos()/setpos() don't include curswant.
Solution:   Add a fifth number when getting/setting the cursor.
Files:	    src/eval.c, src/testdir/test_eval.in, src/testdir/test_eval.ok,
	    runtime/doc/eval.txt


*** ../vim-7.4.309/src/eval.c	2014-05-22 18:59:54.506169240 +0200
--- src/eval.c	2014-05-28 14:23:37.608099523 +0200
***************
*** 764,770 ****
  static void f_writefile __ARGS((typval_T *argvars, typval_T *rettv));
  static void f_xor __ARGS((typval_T *argvars, typval_T *rettv));
  
! static int list2fpos __ARGS((typval_T *arg, pos_T *posp, int *fnump));
  static pos_T *var2fpos __ARGS((typval_T *varp, int dollar_lnum, int *fnum));
  static int get_env_len __ARGS((char_u **arg));
  static int get_id_len __ARGS((char_u **arg));
--- 764,770 ----
  static void f_writefile __ARGS((typval_T *argvars, typval_T *rettv));
  static void f_xor __ARGS((typval_T *argvars, typval_T *rettv));
  
! static int list2fpos __ARGS((typval_T *arg, pos_T *posp, int *fnump, colnr_T *curswantp));
  static pos_T *var2fpos __ARGS((typval_T *varp, int dollar_lnum, int *fnum));
  static int get_env_len __ARGS((char_u **arg));
  static int get_id_len __ARGS((char_u **arg));
***************
*** 9799,9812 ****
      if (argvars[1].v_type == VAR_UNKNOWN)
      {
  	pos_T	    pos;
  
! 	if (list2fpos(argvars, &pos, NULL) == FAIL)
  	    return;
  	line = pos.lnum;
  	col = pos.col;
  #ifdef FEAT_VIRTUALEDIT
  	coladd = pos.coladd;
  #endif
      }
      else
      {
--- 9799,9815 ----
      if (argvars[1].v_type == VAR_UNKNOWN)
      {
  	pos_T	    pos;
+ 	colnr_T	    curswant = -1;
  
! 	if (list2fpos(argvars, &pos, NULL, &curswant) == FAIL)
  	    return;
  	line = pos.lnum;
  	col = pos.col;
  #ifdef FEAT_VIRTUALEDIT
  	coladd = pos.coladd;
  #endif
+ 	if (curswant >= 0)
+ 	    curwin->w_curswant = curswant - 1;
      }
      else
      {
***************
*** 11770,11775 ****
--- 11773,11780 ----
  				(fp != NULL) ? (varnumber_T)fp->coladd :
  #endif
  							      (varnumber_T)0);
+ 	if (fp == &curwin->w_cursor)
+ 	    list_append_number(l, (varnumber_T)curwin->w_curswant + 1);
      }
      else
  	rettv->vval.v_number = FALSE;
***************
*** 16751,16762 ****
      pos_T	pos;
      int		fnum;
      char_u	*name;
  
      rettv->vval.v_number = -1;
      name = get_tv_string_chk(argvars);
      if (name != NULL)
      {
! 	if (list2fpos(&argvars[1], &pos, &fnum) == OK)
  	{
  	    if (--pos.col < 0)
  		pos.col = 0;
--- 16756,16768 ----
      pos_T	pos;
      int		fnum;
      char_u	*name;
+     colnr_T	curswant = -1;
  
      rettv->vval.v_number = -1;
      name = get_tv_string_chk(argvars);
      if (name != NULL)
      {
! 	if (list2fpos(&argvars[1], &pos, &fnum, &curswant) == OK)
  	{
  	    if (--pos.col < 0)
  		pos.col = 0;
***************
*** 16766,16771 ****
--- 16772,16779 ----
  		if (fnum == curbuf->b_fnum)
  		{
  		    curwin->w_cursor = pos;
+ 		    if (curswant >= 0)
+ 			curwin->w_curswant = curswant - 1;
  		    check_cursor();
  		    rettv->vval.v_number = 0;
  		}
***************
*** 19532,19552 ****
   * validity.
   */
      static int
! list2fpos(arg, posp, fnump)
      typval_T	*arg;
      pos_T	*posp;
      int		*fnump;
  {
      list_T	*l = arg->vval.v_list;
      long	i = 0;
      long	n;
  
!     /* List must be: [fnum, lnum, col, coladd], where "fnum" is only there
!      * when "fnump" isn't NULL and "coladd" is optional. */
      if (arg->v_type != VAR_LIST
  	    || l == NULL
  	    || l->lv_len < (fnump == NULL ? 2 : 3)
! 	    || l->lv_len > (fnump == NULL ? 3 : 4))
  	return FAIL;
  
      if (fnump != NULL)
--- 19540,19561 ----
   * validity.
   */
      static int
! list2fpos(arg, posp, fnump, curswantp)
      typval_T	*arg;
      pos_T	*posp;
      int		*fnump;
+     colnr_T	*curswantp;
  {
      list_T	*l = arg->vval.v_list;
      long	i = 0;
      long	n;
  
!     /* List must be: [fnum, lnum, col, coladd, curswant], where "fnum" is only
!      * there when "fnump" isn't NULL; "coladd" and "curswant" are optional. */
      if (arg->v_type != VAR_LIST
  	    || l == NULL
  	    || l->lv_len < (fnump == NULL ? 2 : 3)
! 	    || l->lv_len > (fnump == NULL ? 4 : 5))
  	return FAIL;
  
      if (fnump != NULL)
***************
*** 19570,19582 ****
      posp->col = n;
  
  #ifdef FEAT_VIRTUALEDIT
!     n = list_find_nr(l, i, NULL);
      if (n < 0)
  	posp->coladd = 0;
      else
  	posp->coladd = n;
  #endif
  
      return OK;
  }
  
--- 19579,19594 ----
      posp->col = n;
  
  #ifdef FEAT_VIRTUALEDIT
!     n = list_find_nr(l, i, NULL);	/* off */
      if (n < 0)
  	posp->coladd = 0;
      else
  	posp->coladd = n;
  #endif
  
+     if (curswantp != NULL)
+ 	*curswantp = list_find_nr(l, i + 1, NULL);  /* curswant */
+ 
      return OK;
  }
  
*** ../vim-7.4.309/src/testdir/test_eval.in	2014-04-29 17:41:18.351689927 +0200
--- src/testdir/test_eval.in	2014-05-28 14:22:31.780098947 +0200
***************
*** 190,198 ****
--- 190,207 ----
  :$put =v:exception
  :endtry
  :"
+ :$put ='{{{1 setpos/getpos'
+ /^012345678
+ 6l:let sp = getpos('.')
+ 0:call setpos('.', sp)
+ jyl:$put
+ :"
  :/^start:/+1,$wq! test.out
  :" vim: et ts=4 isk-=\: fmr=???,???
  :call getchar()
  ENDTEST
  
+ 012345678
+ 012345678
+ 
  start:
*** ../vim-7.4.309/src/testdir/test_eval.ok	2014-04-29 17:41:18.351689927 +0200
--- src/testdir/test_eval.ok	2014-05-28 14:19:31.836097372 +0200
***************
*** 346,348 ****
--- 346,350 ----
  Bar exists: 1
  func Bar exists: 1
  Vim(call):E116: Invalid arguments for function append
+ {{{1 setpos/getpos
+ 6
*** ../vim-7.4.309/runtime/doc/eval.txt	2014-05-07 18:35:25.661216052 +0200
--- runtime/doc/eval.txt	2014-05-28 14:04:40.928089573 +0200
***************
*** 2587,2595 ****
  cursor({list})
  		Positions the cursor at the column (byte count) {col} in the
  		line {lnum}.  The first column is one.
  		When there is one argument {list} this is used as a |List|
! 		with two or three items {lnum}, {col} and {off}.  This is like
! 		the return value of |getpos()|, but without the first item.
  		Does not change the jumplist.
  		If {lnum} is greater than the number of lines in the buffer,
  		the cursor will be positioned at the last line in the buffer.
--- 2587,2600 ----
  cursor({list})
  		Positions the cursor at the column (byte count) {col} in the
  		line {lnum}.  The first column is one.
+ 
  		When there is one argument {list} this is used as a |List|
! 		with two, three or four item:
! 			[{lnum}, {col}, {off}]
! 			[{lnum}, {col}, {off}, {curswant}]
! 		This is like the return value of |getpos()|, but without the
! 		first item.
! 
  		Does not change the jumplist.
  		If {lnum} is greater than the number of lines in the buffer,
  		the cursor will be positioned at the last line in the buffer.
***************
*** 4475,4482 ****
  							*getpos()*
  getpos({expr})	Get the position for {expr}.  For possible values of {expr}
  		see |line()|.
! 		The result is a |List| with four numbers:
  		    [bufnum, lnum, col, off]
  		"bufnum" is zero, unless a mark like '0 or 'A is used, then it
  		is the buffer number of the mark.
  		"lnum" and "col" are the position in the buffer.  The first
--- 4490,4498 ----
  							*getpos()*
  getpos({expr})	Get the position for {expr}.  For possible values of {expr}
  		see |line()|.
! 		The result is a |List| with four or five numbers:
  		    [bufnum, lnum, col, off]
+ 		    [bufnum, lnum, col, off, curswant]
  		"bufnum" is zero, unless a mark like '0 or 'A is used, then it
  		is the buffer number of the mark.
  		"lnum" and "col" are the position in the buffer.  The first
***************
*** 4485,4490 ****
--- 4501,4511 ----
  		it is the offset in screen columns from the start of the
  		character.  E.g., a position within a <Tab> or after the last
  		character.
+ 		The "curswant" number is only added for getpos('.'), it is the
+ 		preferred column when moving the cursor vertically.
+ 		Note that for '< and '> Visual mode matters: when it is "V"
+ 		(visual line mode) the column of '< is zero and the column of
+ 		'> is a large number.
  		This can be used to save and restore the cursor position: >
  			let save_cursor = getpos(".")
  			MoveTheCursorAround
***************
*** 5289,5296 ****
  			.	the cursor
  			'x	mark x
  
! 		{list} must be a |List| with four numbers:
  		    [bufnum, lnum, col, off]
  
  		"bufnum" is the buffer number.	Zero can be used for the
  		current buffer.  Setting the cursor is only possible for
--- 5310,5318 ----
  			.	the cursor
  			'x	mark x
  
! 		{list} must be a |List| with four or five numbers:
  		    [bufnum, lnum, col, off]
+ 		    [bufnum, lnum, col, off, curswant]
  
  		"bufnum" is the buffer number.	Zero can be used for the
  		current buffer.  Setting the cursor is only possible for
***************
*** 5308,5320 ****
  		character.  E.g., a position within a <Tab> or after the last
  		character.
  
  		Returns 0 when the position could be set, -1 otherwise.
  		An error message is given if {expr} is invalid.
  
  		Also see |getpos()|
  
  		This does not restore the preferred column for moving
! 		vertically.  See |winrestview()| for that.
  
  
  setqflist({list} [, {action}])				*setqflist()*
--- 5330,5355 ----
  		character.  E.g., a position within a <Tab> or after the last
  		character.
  
+ 		The "curswant" number is only used when setting the cursor
+ 		position.  It sets the preferred column for when moving the
+ 		cursor vertically.  When the "curswant" number is missing the
+ 		preferred column is not set.  When it is present and setting a
+ 		mark position it is not used.
+ 
+ 		Note that for '< and '> changing the line number may result in
+ 		the marks to be effectively be swapped, so that '< is always
+ 		before '>.
+ 
  		Returns 0 when the position could be set, -1 otherwise.
  		An error message is given if {expr} is invalid.
  
  		Also see |getpos()|
  
  		This does not restore the preferred column for moving
! 		vertically; if you set the cursor position with this, |j| and
! 		|k| motions will jump to previous columns!  Use |cursor()| to
! 		also set the preferred column.  Also see the "curswant" key in
! 		|winrestview()|.
  
  
  setqflist({list} [, {action}])				*setqflist()*
*** ../vim-7.4.309/src/version.c	2014-05-28 13:42:59.884078184 +0200
--- src/version.c	2014-05-28 14:27:20.132101471 +0200
***************
*** 736,737 ****
--- 736,739 ----
  {   /* Add new patch number below this line */
+ /**/
+     310,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
218. Your spouse hands you a gift wrapped magnet with your PC's name
     on it and you accuse him or her of genocide.

 /// 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    ///