mirror of
https://github.com/neovim/neovim.git
synced 2025-10-09 11:26:37 +00:00
vim-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 vim/vim#10135,
closes vim/vim#2173)
db0ea7f2b0
Cherry-pick FOR_ALL_BUF_WININFO from patch 8.2.0500.
Cherry-pick test_changelist.vim change from patch 8.2.3795.
This commit is contained in:
@@ -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) {
|
||||
|
Reference in New Issue
Block a user