Mercurial > vim
diff src/evalfunc.c @ 22357:0e231e8e70f8 v8.2.1727
patch 8.2.1727: a popup created with "cursorline" will ignore "firstline"
Commit: https://github.com/vim/vim/commit/99ca9c4868bb1669706b9e3de9a9218bd11cc459
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Sep 22 21:55:41 2020 +0200
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().
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 22 Sep 2020 22:00:03 +0200 |
parents | 0491b9cafd44 |
children | 00f2eebe74d9 |
line wrap: on
line diff
--- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -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;