Skip to content

Commit 9b7d8cd

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 0cc550e + 0c4dc88 commit 9b7d8cd

4 files changed

Lines changed: 53 additions & 9 deletions

File tree

src/evalfunc.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9918,7 +9918,8 @@ set_buffer_lines(buf_T *buf, linenr_T lnum, typval_T *lines, typval_T *rettv)
99189918
listitem_T *li = NULL;
99199919
long added = 0;
99209920
linenr_T lcount;
9921-
buf_T *curbuf_save;
9921+
buf_T *curbuf_save = NULL;
9922+
win_T *curwin_save = NULL;
99229923
int is_curbuf = buf == curbuf;
99239924

99249925
/* When using the current buffer ml_mfp will be set if needed. Useful when
@@ -9930,8 +9931,22 @@ set_buffer_lines(buf_T *buf, linenr_T lnum, typval_T *lines, typval_T *rettv)
99309931
return;
99319932
}
99329933

9933-
curbuf_save = curbuf;
9934-
curbuf = buf;
9934+
if (!is_curbuf)
9935+
{
9936+
wininfo_T *wip;
9937+
9938+
curbuf_save = curbuf;
9939+
curwin_save = curwin;
9940+
curbuf = buf;
9941+
for (wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next)
9942+
{
9943+
if (wip->wi_win != NULL)
9944+
{
9945+
curwin = wip->wi_win;
9946+
break;
9947+
}
9948+
}
9949+
}
99359950

99369951
lcount = curbuf->b_ml.ml_line_count;
99379952

@@ -9994,7 +10009,11 @@ set_buffer_lines(buf_T *buf, linenr_T lnum, typval_T *lines, typval_T *rettv)
999410009
if (added > 0)
999510010
appended_lines_mark(lcount, added);
999610011

9997-
curbuf = curbuf_save;
10012+
if (!is_curbuf)
10013+
{
10014+
curbuf = curbuf_save;
10015+
curwin = curwin_save;
10016+
}
999810017
}
999910018

1000010019
/*

src/testdir/test_bufline.vim

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,32 @@ func Test_setbufline_getbufline()
2727
exe "bwipe! " . b
2828
endfunc
2929

30+
func Test_setbufline_getbufline_fold()
31+
split Xtest
32+
setlocal foldmethod=expr foldexpr=0
33+
let b = bufnr('%')
34+
new
35+
call assert_equal(0, setbufline(b, 1, ['foo', 'bar']))
36+
call assert_equal(['foo'], getbufline(b, 1))
37+
call assert_equal(['bar'], getbufline(b, 2))
38+
call assert_equal(['foo', 'bar'], getbufline(b, 1, 2))
39+
exe "bwipe!" b
40+
bwipe!
41+
endfunc
42+
43+
func Test_setbufline_getbufline_fold_tab()
44+
split Xtest
45+
setlocal foldmethod=expr foldexpr=0
46+
let b = bufnr('%')
47+
tab new
48+
call assert_equal(0, setbufline(b, 1, ['foo', 'bar']))
49+
call assert_equal(['foo'], getbufline(b, 1))
50+
call assert_equal(['bar'], getbufline(b, 2))
51+
call assert_equal(['foo', 'bar'], getbufline(b, 1, 2))
52+
exe "bwipe!" b
53+
bwipe!
54+
endfunc
55+
3056
func Test_setline_startup()
3157
let cmd = GetVimCommand('Xscript')
3258
if cmd == ''

src/testdir/test_search_mbyte.ok

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/version.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,10 @@ static char *(features[]) =
776776

777777
static int included_patches[] =
778778
{ /* Add new patch number below this line */
779+
/**/
780+
1274,
781+
/**/
782+
1273,
779783
/**/
780784
1272,
781785
/**/

0 commit comments

Comments
 (0)