mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #919 from munshkr/p7.4.310
vim-patch:7.4.310, vim-patch:7.4.313
This commit is contained in:
commit
8249e4ac72
@ -6387,6 +6387,7 @@ static struct fst {
|
|||||||
{"getcmdline", 0, 0, f_getcmdline},
|
{"getcmdline", 0, 0, f_getcmdline},
|
||||||
{"getcmdpos", 0, 0, f_getcmdpos},
|
{"getcmdpos", 0, 0, f_getcmdpos},
|
||||||
{"getcmdtype", 0, 0, f_getcmdtype},
|
{"getcmdtype", 0, 0, f_getcmdtype},
|
||||||
|
{"getcurpos", 0, 0, f_getcurpos},
|
||||||
{"getcwd", 0, 0, f_getcwd},
|
{"getcwd", 0, 0, f_getcwd},
|
||||||
{"getfontname", 0, 1, f_getfontname},
|
{"getfontname", 0, 1, f_getfontname},
|
||||||
{"getfperm", 1, 1, f_getfperm},
|
{"getfperm", 1, 1, f_getfperm},
|
||||||
@ -7863,12 +7864,17 @@ static void f_cursor(typval_T *argvars, typval_T *rettv)
|
|||||||
rettv->vval.v_number = -1;
|
rettv->vval.v_number = -1;
|
||||||
if (argvars[1].v_type == VAR_UNKNOWN) {
|
if (argvars[1].v_type == VAR_UNKNOWN) {
|
||||||
pos_T pos;
|
pos_T pos;
|
||||||
|
colnr_T curswant = -1;
|
||||||
|
|
||||||
if (list2fpos(argvars, &pos, NULL) == FAIL)
|
if (list2fpos(argvars, &pos, NULL, &curswant) == FAIL) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
line = pos.lnum;
|
line = pos.lnum;
|
||||||
col = pos.col;
|
col = pos.col;
|
||||||
coladd = pos.coladd;
|
coladd = pos.coladd;
|
||||||
|
if (curswant >= 0) {
|
||||||
|
curwin->w_curswant = curswant - 1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
line = get_tv_lnum(argvars);
|
line = get_tv_lnum(argvars);
|
||||||
col = get_tv_number_chk(&argvars[1], NULL);
|
col = get_tv_number_chk(&argvars[1], NULL);
|
||||||
@ -9373,10 +9379,7 @@ static void f_getpid(typval_T *argvars, typval_T *rettv)
|
|||||||
rettv->vval.v_number = os_get_pid();
|
rettv->vval.v_number = os_get_pid();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static void getpos_both(typval_T *argvars, typval_T *rettv, bool getcurpos)
|
||||||
* "getpos(string)" function
|
|
||||||
*/
|
|
||||||
static void f_getpos(typval_T *argvars, typval_T *rettv)
|
|
||||||
{
|
{
|
||||||
pos_T *fp;
|
pos_T *fp;
|
||||||
list_T *l;
|
list_T *l;
|
||||||
@ -9384,7 +9387,11 @@ static void f_getpos(typval_T *argvars, typval_T *rettv)
|
|||||||
|
|
||||||
rettv_list_alloc(rettv);
|
rettv_list_alloc(rettv);
|
||||||
l = rettv->vval.v_list;
|
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, (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, (fp != NULL) ? (varnumber_T)fp->lnum : (varnumber_T)0);
|
||||||
list_append_number(l,
|
list_append_number(l,
|
||||||
@ -9393,6 +9400,25 @@ static void f_getpos(typval_T *argvars, typval_T *rettv)
|
|||||||
: (varnumber_T)0);
|
: (varnumber_T)0);
|
||||||
list_append_number(l,
|
list_append_number(l,
|
||||||
(fp != NULL) ? (varnumber_T)fp->coladd : (varnumber_T)0);
|
(fp != NULL) ? (varnumber_T)fp->coladd : (varnumber_T)0);
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -13118,17 +13144,21 @@ static void f_setpos(typval_T *argvars, typval_T *rettv)
|
|||||||
pos_T pos;
|
pos_T pos;
|
||||||
int fnum;
|
int fnum;
|
||||||
char_u *name;
|
char_u *name;
|
||||||
|
colnr_T curswant = -1;
|
||||||
|
|
||||||
rettv->vval.v_number = -1;
|
rettv->vval.v_number = -1;
|
||||||
name = get_tv_string_chk(argvars);
|
name = get_tv_string_chk(argvars);
|
||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
if (list2fpos(&argvars[1], &pos, &fnum) == OK) {
|
if (list2fpos(&argvars[1], &pos, &fnum, &curswant) == OK) {
|
||||||
if (--pos.col < 0)
|
if (--pos.col < 0)
|
||||||
pos.col = 0;
|
pos.col = 0;
|
||||||
if (name[0] == '.' && name[1] == NUL) {
|
if (name[0] == '.' && name[1] == NUL) {
|
||||||
/* set cursor */
|
/* set cursor */
|
||||||
if (fnum == curbuf->b_fnum) {
|
if (fnum == curbuf->b_fnum) {
|
||||||
curwin->w_cursor = pos;
|
curwin->w_cursor = pos;
|
||||||
|
if (curswant >= 0) {
|
||||||
|
curwin->w_curswant = curswant - 1;
|
||||||
|
}
|
||||||
check_cursor();
|
check_cursor();
|
||||||
rettv->vval.v_number = 0;
|
rettv->vval.v_number = 0;
|
||||||
} else
|
} else
|
||||||
@ -15177,18 +15207,18 @@ var2fpos (
|
|||||||
* Return FAIL when conversion is not possible, doesn't check the position for
|
* Return FAIL when conversion is not possible, doesn't check the position for
|
||||||
* validity.
|
* validity.
|
||||||
*/
|
*/
|
||||||
static int list2fpos(typval_T *arg, pos_T *posp, int *fnump)
|
static int list2fpos(typval_T *arg, pos_T *posp, int *fnump, colnr_T *curswantp)
|
||||||
{
|
{
|
||||||
list_T *l = arg->vval.v_list;
|
list_T *l = arg->vval.v_list;
|
||||||
long i = 0;
|
long i = 0;
|
||||||
long n;
|
long n;
|
||||||
|
|
||||||
/* List must be: [fnum, lnum, col, coladd], where "fnum" is only there
|
/* List must be: [fnum, lnum, col, coladd, curswant], where "fnum" is only
|
||||||
* when "fnump" isn't NULL and "coladd" is optional. */
|
* there when "fnump" isn't NULL; "coladd" and "curswant" are optional. */
|
||||||
if (arg->v_type != VAR_LIST
|
if (arg->v_type != VAR_LIST
|
||||||
|| l == NULL
|
|| l == NULL
|
||||||
|| l->lv_len < (fnump == NULL ? 2 : 3)
|
|| l->lv_len < (fnump == NULL ? 2 : 3)
|
||||||
|| l->lv_len > (fnump == NULL ? 3 : 4))
|
|| l->lv_len > (fnump == NULL ? 4 : 5))
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
if (fnump != NULL) {
|
if (fnump != NULL) {
|
||||||
@ -15210,12 +15240,16 @@ static int list2fpos(typval_T *arg, pos_T *posp, int *fnump)
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
posp->col = n;
|
posp->col = n;
|
||||||
|
|
||||||
n = list_find_nr(l, i, NULL);
|
n = list_find_nr(l, i, NULL); // off
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
posp->coladd = 0;
|
posp->coladd = 0;
|
||||||
else
|
else
|
||||||
posp->coladd = n;
|
posp->coladd = n;
|
||||||
|
|
||||||
|
if (curswantp != NULL) {
|
||||||
|
*curswantp = list_find_nr(l, i + 1, NULL); // curswant
|
||||||
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
STARTTEST
|
STARTTEST
|
||||||
|
:so small.vim
|
||||||
:e test.out
|
:set encoding=latin1
|
||||||
:%d
|
:set noswapfile
|
||||||
|
|
||||||
:" function name not starting with a capital
|
:" function name not starting with a capital
|
||||||
:try
|
:try
|
||||||
@ -49,9 +49,18 @@ STARTTEST
|
|||||||
: $put =v:exception
|
: $put =v:exception
|
||||||
:endtry
|
:endtry
|
||||||
|
|
||||||
:1d
|
:$put ='{{{1 getcurpos/setpos'
|
||||||
:w
|
/^012345678
|
||||||
:qa!
|
6l:let sp = getcurpos()
|
||||||
|
0:call setpos('.', sp)
|
||||||
|
jyl:$put
|
||||||
|
|
||||||
|
:/^start:/+1,$wq! test.out
|
||||||
|
:" vim: et ts=4 isk-=\: fmr=???,???
|
||||||
|
:call getchar()
|
||||||
ENDTEST
|
ENDTEST
|
||||||
|
|
||||||
|
012345678
|
||||||
|
012345678
|
||||||
|
|
||||||
|
start:
|
||||||
|
@ -9,3 +9,5 @@ func s:Testje exists: 1
|
|||||||
Bar exists: 1
|
Bar exists: 1
|
||||||
func Bar exists: 1
|
func Bar exists: 1
|
||||||
Vim(call):E116: Invalid arguments for function append
|
Vim(call):E116: Invalid arguments for function append
|
||||||
|
{{{1 getcurpos/setpos
|
||||||
|
6
|
||||||
|
@ -282,10 +282,10 @@ static int included_patches[] = {
|
|||||||
//316 NA
|
//316 NA
|
||||||
315,
|
315,
|
||||||
314,
|
314,
|
||||||
//313,
|
313,
|
||||||
312,
|
312,
|
||||||
//311,
|
//311,
|
||||||
//310,
|
310,
|
||||||
309,
|
309,
|
||||||
308,
|
308,
|
||||||
//307 NA
|
//307 NA
|
||||||
|
Loading…
Reference in New Issue
Block a user