0
0
mirror of https://github.com/vim/vim.git synced 2025-10-13 06:54:15 -04:00

patch 8.0.1274: setbufline() fails when using folding

Problem:    setbufline() fails when using folding.
Solution:   Set "curwin" if needed. (Ozaki Kiichi, closes #2293)
This commit is contained in:
Bram Moolenaar
2017-11-06 21:32:54 +01:00
parent 4148be468f
commit 0c4dc88a63
3 changed files with 51 additions and 4 deletions

View File

@@ -9891,7 +9891,8 @@ set_buffer_lines(buf_T *buf, linenr_T lnum, typval_T *lines, typval_T *rettv)
listitem_T *li = NULL;
long added = 0;
linenr_T lcount;
buf_T *curbuf_save;
buf_T *curbuf_save = NULL;
win_T *curwin_save = NULL;
int is_curbuf = buf == curbuf;
/* When using the current buffer ml_mfp will be set if needed. Useful when
@@ -9903,8 +9904,22 @@ set_buffer_lines(buf_T *buf, linenr_T lnum, typval_T *lines, typval_T *rettv)
return;
}
curbuf_save = curbuf;
curbuf = buf;
if (!is_curbuf)
{
wininfo_T *wip;
curbuf_save = curbuf;
curwin_save = curwin;
curbuf = buf;
for (wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next)
{
if (wip->wi_win != NULL)
{
curwin = wip->wi_win;
break;
}
}
}
lcount = curbuf->b_ml.ml_line_count;
@@ -9967,7 +9982,11 @@ set_buffer_lines(buf_T *buf, linenr_T lnum, typval_T *lines, typval_T *rettv)
if (added > 0)
appended_lines_mark(lcount, added);
curbuf = curbuf_save;
if (!is_curbuf)
{
curbuf = curbuf_save;
curwin = curwin_save;
}
}
/*