buffer: fix copying setl options for buffer currently displayed in another window

vim-patch:8.0.1836: buffer-local window options may not be recent
Problem:    Buffer-local window options may not be recent if the buffer is
            still open in another window.
Solution:   Copy the options from the window instead of the outdated window
            options. (Bjorn Linse, closes vim/vim#2336)
25782a7ff4
This commit is contained in:
Björn Linse
2017-11-13 19:55:20 +01:00
parent 7ae7da8fb9
commit 8917e0c301
2 changed files with 61 additions and 2 deletions

View File

@@ -2381,8 +2381,15 @@ void get_winopts(buf_T *buf)
clear_winopt(&curwin->w_onebuf_opt);
clearFolding(curwin);
wip = find_wininfo(buf, TRUE);
if (wip != NULL && wip->wi_optset) {
wip = find_wininfo(buf, true);
if (wip != NULL && wip->wi_win != curwin && wip->wi_win != NULL
&& wip->wi_win->w_buffer == buf) {
win_T *wp = wip->wi_win;
copy_winopt(&wp->w_onebuf_opt, &curwin->w_onebuf_opt);
curwin->w_fold_manual = wp->w_fold_manual;
curwin->w_foldinvalid = true;
cloneFoldGrowArray(&wp->w_folds, &curwin->w_folds);
} else if (wip != NULL && wip->wi_optset) {
copy_winopt(&wip->wi_opt, &curwin->w_onebuf_opt);
curwin->w_fold_manual = wip->wi_fold_manual;
curwin->w_foldinvalid = true;