vim-patch:7.4.313

Problem:    Changing the return value of getpos() causes an error.  (Jie Zhu)
Solution:   Revert getpos() and add getcurpos().

https://code.google.com/p/vim/source/detail?r=332a5c2b2956d9b18d85268a724d01deea27ec83
This commit is contained in:
Damián Silvani 2014-08-03 10:39:56 -03:00
parent 27f423e734
commit e32d338c87
4 changed files with 28 additions and 10 deletions

View File

@ -6387,6 +6387,7 @@ static struct fst {
{"getcmdline", 0, 0, f_getcmdline},
{"getcmdpos", 0, 0, f_getcmdpos},
{"getcmdtype", 0, 0, f_getcmdtype},
{"getcurpos", 0, 0, f_getcurpos},
{"getcwd", 0, 0, f_getcwd},
{"getfontname", 0, 1, f_getfontname},
{"getfperm", 1, 1, f_getfperm},
@ -9378,10 +9379,7 @@ static void f_getpid(typval_T *argvars, typval_T *rettv)
rettv->vval.v_number = os_get_pid();
}
/*
* "getpos(string)" function
*/
static void f_getpos(typval_T *argvars, typval_T *rettv)
static void getpos_both(typval_T *argvars, typval_T *rettv, bool getcurpos)
{
pos_T *fp;
list_T *l;
@ -9389,7 +9387,11 @@ static void f_getpos(typval_T *argvars, typval_T *rettv)
rettv_list_alloc(rettv);
l = rettv->vval.v_list;
fp = var2fpos(&argvars[0], TRUE, &fnum);
if (getcurpos) {
fp = &curwin->w_cursor;
} else {
fp = var2fpos(&argvars[0], true, &fnum);
}
list_append_number(l, (fnum != -1) ? (varnumber_T)fnum : (varnumber_T)0);
list_append_number(l, (fp != NULL) ? (varnumber_T)fp->lnum : (varnumber_T)0);
list_append_number(l,
@ -9398,11 +9400,27 @@ static void f_getpos(typval_T *argvars, typval_T *rettv)
: (varnumber_T)0);
list_append_number(l,
(fp != NULL) ? (varnumber_T)fp->coladd : (varnumber_T)0);
if (fp == &curwin->w_cursor) {
if (getcurpos) {
list_append_number(l, (varnumber_T) curwin->w_curswant + 1);
}
}
/*
* "getcurpos(string)" function
*/
static void f_getcurpos(typval_T *argvars, typval_T *rettv)
{
getpos_both(argvars, rettv, true);
}
/*
* "getpos(string)" function
*/
static void f_getpos(typval_T *argvars, typval_T *rettv)
{
getpos_both(argvars, rettv, false);
}
/*
* "getqflist()" and "getloclist()" functions
*/

View File

@ -49,9 +49,9 @@ STARTTEST
: $put =v:exception
:endtry
:$put ='{{{1 setpos/getpos'
:$put ='{{{1 getcurpos/setpos'
/^012345678
6l:let sp = getpos('.')
6l:let sp = getcurpos()
0:call setpos('.', sp)
jyl:$put

View File

@ -9,5 +9,5 @@ func s:Testje exists: 1
Bar exists: 1
func Bar exists: 1
Vim(call):E116: Invalid arguments for function append
{{{1 setpos/getpos
{{{1 getcurpos/setpos
6

View File

@ -282,7 +282,7 @@ static int included_patches[] = {
//316 NA
315,
314,
//313,
313,
312,
//311,
310,