Mercurial > vim
diff src/evalfunc.c @ 28413:1170b35651a5 v8.2.4731
patch 8.2.4731: the changelist index is not remembered per buffer
Commit: https://github.com/vim/vim/commit/db0ea7f2b00c84d84f188c9e9953c4f1887528e7
Author: LemonBoy <thatlemon@gmail.com>
Date: Sun Apr 10 17:59:26 2022 +0100
patch 8.2.4731: the changelist index is not remembered per buffer
Problem: The changelist index is not remembered per buffer.
Solution: Keep the changelist index per window and buffer. (closes https://github.com/vim/vim/issues/10135,
closes #2173)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 10 Apr 2022 19:00:03 +0200 |
parents | 425700af491b |
children | 4fbdd4ce9edb |
line wrap: on
line diff
--- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -4724,6 +4724,7 @@ f_getchangelist(typval_T *argvars, typva int i; list_T *l; dict_T *d; + int changelistindex; if (rettv_list_alloc(rettv) != OK) return; @@ -4745,13 +4746,25 @@ f_getchangelist(typval_T *argvars, typva if (list_append_list(rettv->vval.v_list, l) == FAIL) return; /* - * 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. + * 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. */ - list_append_number(rettv->vval.v_list, - (varnumber_T)((buf == curwin->w_buffer) - ? curwin->w_changelistidx : buf->b_changelistlen)); + 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; + } + list_append_number(rettv->vval.v_list, (varnumber_T)changelistindex); for (i = 0; i < buf->b_changelistlen; ++i) {