comparison src/evalfunc.c @ 12794:d4fc8a7dc7d9 v8.0.1274

patch 8.0.1274: setbufline() fails when using folding commit https://github.com/vim/vim/commit/0c4dc88a637a5027209aa00226996af84e248636 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Nov 6 21:32:54 2017 +0100 patch 8.0.1274: setbufline() fails when using folding Problem: setbufline() fails when using folding. Solution: Set "curwin" if needed. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/2293)
author Christian Brabandt <cb@256bit.org>
date Mon, 06 Nov 2017 21:45:04 +0100
parents 7749260f261c
children 963cdeb42c41
comparison
equal deleted inserted replaced
12793:782ecfa50400 12794:d4fc8a7dc7d9
9889 char_u *line = NULL; 9889 char_u *line = NULL;
9890 list_T *l = NULL; 9890 list_T *l = NULL;
9891 listitem_T *li = NULL; 9891 listitem_T *li = NULL;
9892 long added = 0; 9892 long added = 0;
9893 linenr_T lcount; 9893 linenr_T lcount;
9894 buf_T *curbuf_save; 9894 buf_T *curbuf_save = NULL;
9895 win_T *curwin_save = NULL;
9895 int is_curbuf = buf == curbuf; 9896 int is_curbuf = buf == curbuf;
9896 9897
9897 /* When using the current buffer ml_mfp will be set if needed. Useful when 9898 /* When using the current buffer ml_mfp will be set if needed. Useful when
9898 * setline() is used on startup. For other buffers the buffer must be 9899 * setline() is used on startup. For other buffers the buffer must be
9899 * loaded. */ 9900 * loaded. */
9901 { 9902 {
9902 rettv->vval.v_number = 1; /* FAIL */ 9903 rettv->vval.v_number = 1; /* FAIL */
9903 return; 9904 return;
9904 } 9905 }
9905 9906
9906 curbuf_save = curbuf; 9907 if (!is_curbuf)
9907 curbuf = buf; 9908 {
9909 wininfo_T *wip;
9910
9911 curbuf_save = curbuf;
9912 curwin_save = curwin;
9913 curbuf = buf;
9914 for (wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next)
9915 {
9916 if (wip->wi_win != NULL)
9917 {
9918 curwin = wip->wi_win;
9919 break;
9920 }
9921 }
9922 }
9908 9923
9909 lcount = curbuf->b_ml.ml_line_count; 9924 lcount = curbuf->b_ml.ml_line_count;
9910 9925
9911 if (lines->v_type == VAR_LIST) 9926 if (lines->v_type == VAR_LIST)
9912 { 9927 {
9965 } 9980 }
9966 9981
9967 if (added > 0) 9982 if (added > 0)
9968 appended_lines_mark(lcount, added); 9983 appended_lines_mark(lcount, added);
9969 9984
9970 curbuf = curbuf_save; 9985 if (!is_curbuf)
9986 {
9987 curbuf = curbuf_save;
9988 curwin = curwin_save;
9989 }
9971 } 9990 }
9972 9991
9973 /* 9992 /*
9974 * "setbufline()" function 9993 * "setbufline()" function
9975 */ 9994 */