mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
updated for version 7.4.310
Problem: getpos()/setpos() don't include curswant. Solution: Add a fifth number when getting/setting the cursor.
This commit is contained in:
28
src/eval.c
28
src/eval.c
@@ -764,7 +764,7 @@ static void f_winwidth __ARGS((typval_T *argvars, typval_T *rettv));
|
||||
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 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,14 +9799,17 @@ f_cursor(argvars, rettv)
|
||||
if (argvars[1].v_type == VAR_UNKNOWN)
|
||||
{
|
||||
pos_T pos;
|
||||
colnr_T curswant = -1;
|
||||
|
||||
if (list2fpos(argvars, &pos, NULL) == FAIL)
|
||||
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,6 +11773,8 @@ f_getpos(argvars, rettv)
|
||||
(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,12 +16756,13 @@ f_setpos(argvars, rettv)
|
||||
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) == OK)
|
||||
if (list2fpos(&argvars[1], &pos, &fnum, &curswant) == OK)
|
||||
{
|
||||
if (--pos.col < 0)
|
||||
pos.col = 0;
|
||||
@@ -16766,6 +16772,8 @@ f_setpos(argvars, rettv)
|
||||
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,21 +19540,22 @@ var2fpos(varp, dollar_lnum, fnum)
|
||||
* validity.
|
||||
*/
|
||||
static int
|
||||
list2fpos(arg, posp, fnump)
|
||||
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], where "fnum" is only there
|
||||
* when "fnump" isn't NULL and "coladd" is optional. */
|
||||
/* 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 ? 3 : 4))
|
||||
|| l->lv_len > (fnump == NULL ? 4 : 5))
|
||||
return FAIL;
|
||||
|
||||
if (fnump != NULL)
|
||||
@@ -19570,13 +19579,16 @@ list2fpos(arg, posp, fnump)
|
||||
posp->col = n;
|
||||
|
||||
#ifdef FEAT_VIRTUALEDIT
|
||||
n = list_find_nr(l, i, NULL);
|
||||
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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user