summaryrefslogtreecommitdiffstats
path: root/src/evalfunc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/evalfunc.c')
-rw-r--r--src/evalfunc.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 4829673464..e56b505d2b 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -4724,6 +4724,7 @@ f_getchangelist(typval_T *argvars, typval_T *rettv)
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, typval_T *rettv)
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)
{