diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-07-23 10:15:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-23 10:15:57 +0800 |
commit | d0ced2a127ab3974deaefcfab214b564b1ef48e7 (patch) | |
tree | e9adaa0a0c77e8d7d2b23006cf253cf572e34513 /src/nvim/eval/funcs.c | |
parent | ed6bbc03af7be192e3d615f8ee761611e78d9881 (diff) | |
parent | 9d556fc81f379aba21459bd0359e6bcd38384bfd (diff) | |
download | rneovim-d0ced2a127ab3974deaefcfab214b564b1ef48e7.tar.gz rneovim-d0ced2a127ab3974deaefcfab214b564b1ef48e7.tar.bz2 rneovim-d0ced2a127ab3974deaefcfab214b564b1ef48e7.zip |
Merge pull request #19471 from zeertzjq/vim-8.2.4731
vim-patch:8.2.{4731,5035}: changelist patches
Diffstat (limited to 'src/nvim/eval/funcs.c')
-rw-r--r-- | src/nvim/eval/funcs.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 5ee499e006..dac6bb6e34 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -2824,13 +2824,23 @@ static void f_getchangelist(typval_T *argvars, typval_T *rettv, FunPtr fptr) list_T *const l = tv_list_alloc(buf->b_changelistlen); tv_list_append_list(rettv->vval.v_list, l); - // The current window change list index tracks only the position in the - // current buffer change list. For other buffers, use the change list - // length as the current index. - tv_list_append_number(rettv->vval.v_list, - (buf == curwin->w_buffer) - ? curwin->w_changelistidx - : buf->b_changelistlen); + // The current window change list index tracks only the position for the + // current buffer. For other buffers use the stored index for the current + // window, or, if that's not available, the change list length. + int changelistindex; + if (buf == curwin->w_buffer) { + changelistindex = curwin->w_changelistidx; + } else { + wininfo_T *wip; + + FOR_ALL_BUF_WININFO(buf, wip) { + if (wip->wi_win == curwin) { + break; + } + } + changelistindex = wip != NULL ? wip->wi_changelistidx : buf->b_changelistlen; + } + tv_list_append_number(rettv->vval.v_list, (varnumber_T)changelistindex); for (int i = 0; i < buf->b_changelistlen; i++) { if (buf->b_changelist[i].mark.lnum == 0) { |