0
0
mirror of https://github.com/vim/vim.git synced 2025-10-13 06:54:15 -04:00

patch 8.2.1727: a popup created with "cursorline" will ignore "firstline"

Problem:    A popup created with "cursorline" will ignore "firstline".
Solution:   When both "cursorline" and "firstline" are present put the cursor
            on "firstline". (closes #7000)  Add the "winid" argument to
            getcurpos().
This commit is contained in:
Bram Moolenaar
2020-09-22 21:55:41 +02:00
parent 4f73b8e9cc
commit 99ca9c4868
7 changed files with 89 additions and 14 deletions

View File

@@ -646,7 +646,7 @@ static funcentry_T global_functions[] =
{"getcmdtype", 0, 0, 0, ret_string, f_getcmdtype},
{"getcmdwintype", 0, 0, 0, ret_string, f_getcmdwintype},
{"getcompletion", 2, 3, FEARG_1, ret_list_string, f_getcompletion},
{"getcurpos", 0, 0, 0, ret_list_number, f_getcurpos},
{"getcurpos", 0, 1, FEARG_1, ret_list_number, f_getcurpos},
{"getcwd", 0, 2, FEARG_1, ret_string, f_getcwd},
{"getenv", 1, 1, FEARG_1, ret_string, f_getenv},
{"getfontname", 0, 1, 0, ret_string, f_getfontname},
@@ -3259,7 +3259,8 @@ getpos_both(
typval_T *rettv,
int getcurpos)
{
pos_T *fp;
pos_T *fp = NULL;
win_T *wp = curwin;
list_T *l;
int fnum = -1;
@@ -3267,7 +3268,16 @@ getpos_both(
{
l = rettv->vval.v_list;
if (getcurpos)
fp = &curwin->w_cursor;
{
if (argvars[0].v_type != VAR_UNKNOWN)
{
wp = find_win_by_nr_or_id(&argvars[0]);
if (wp != NULL)
fp = &wp->w_cursor;
}
else
fp = &curwin->w_cursor;
}
else
fp = var2fpos(&argvars[0], TRUE, &fnum);
if (fnum != -1)
@@ -3287,13 +3297,14 @@ getpos_both(
colnr_T save_curswant = curwin->w_curswant;
colnr_T save_virtcol = curwin->w_virtcol;
update_curswant();
list_append_number(l, curwin->w_curswant == MAXCOL ?
(varnumber_T)MAXCOL : (varnumber_T)curwin->w_curswant + 1);
if (wp == curwin)
update_curswant();
list_append_number(l, wp == NULL ? 0 : wp->w_curswant == MAXCOL
? (varnumber_T)MAXCOL : (varnumber_T)wp->w_curswant + 1);
// Do not change "curswant", as it is unexpected that a get
// function has a side effect.
if (save_set_curswant)
if (wp == curwin && save_set_curswant)
{
curwin->w_set_curswant = save_set_curswant;
curwin->w_curswant = save_curswant;