diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-02-06 04:46:16 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-02-06 04:46:16 +0800 |
commit | 8ba9f19961d8573dc851d3d5f2ec217ad2fb7b28 (patch) | |
tree | dcade506fff3749f5561d947067e730ca66cf126 /src/nvim/eval/funcs.c | |
parent | 92e92f02e7106fcad1597bb8f0edf1e43186a07f (diff) | |
download | rneovim-8ba9f19961d8573dc851d3d5f2ec217ad2fb7b28.tar.gz rneovim-8ba9f19961d8573dc851d3d5f2ec217ad2fb7b28.tar.bz2 rneovim-8ba9f19961d8573dc851d3d5f2ec217ad2fb7b28.zip |
vim-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 vim/vim#7000) Add the "winid" argument to
getcurpos().
https://github.com/vim/vim/commit/99ca9c4868bb1669706b9e3de9a9218bd11cc459
Skip popup window related code.
Cherry-pick all of Test_getcurpos_setpos() from patch 8.2.0610.
Diffstat (limited to 'src/nvim/eval/funcs.c')
-rw-r--r-- | src/nvim/eval/funcs.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index b96ff50787..eb9c08c8f0 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -3845,37 +3845,45 @@ static void f_getpid(typval_T *argvars, typval_T *rettv, FunPtr fptr) static void getpos_both(typval_T *argvars, typval_T *rettv, bool getcurpos) { - pos_T *fp; + pos_T *fp = NULL; + win_T *wp = curwin; int fnum = -1; 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); } list_T *const l = tv_list_alloc_ret(rettv, 4 + (!!getcurpos)); tv_list_append_number(l, (fnum != -1) ? (varnumber_T)fnum : (varnumber_T)0); + tv_list_append_number(l, ((fp != NULL) ? (varnumber_T)fp->lnum : (varnumber_T)0)); tv_list_append_number(l, ((fp != NULL) - ? (varnumber_T)fp->lnum + ? (varnumber_T)(fp->col == MAXCOL ? MAXCOL : fp->col + 1) : (varnumber_T)0)); - tv_list_append_number(l, ((fp != NULL) - ? (varnumber_T)(fp->col == MAXCOL ? MAXCOL : fp->col + 1) - : (varnumber_T)0)); tv_list_append_number(l, (fp != NULL) ? (varnumber_T)fp->coladd : (varnumber_T)0); if (getcurpos) { const int save_set_curswant = curwin->w_set_curswant; const colnr_T save_curswant = curwin->w_curswant; const colnr_T save_virtcol = curwin->w_virtcol; - update_curswant(); - tv_list_append_number(l, (curwin->w_curswant == MAXCOL - ? (varnumber_T)MAXCOL - : (varnumber_T)curwin->w_curswant + 1)); + if (wp == curwin) { + update_curswant(); + } + tv_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; curwin->w_virtcol = save_virtcol; |