summaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-05-13 18:05:33 +0200
committerBram Moolenaar <Bram@vim.org>2018-05-13 18:05:33 +0200
commit25782a7ff4755daf16c2e1cb5e5f826b13b672ce (patch)
tree7c8842590d4759e55af0424ebabc2852df5c0574 /src/buffer.c
parent2290b1f8aaafbcb38bd801d08e8bf86cb07abfa5 (diff)
patch 8.0.1836: buffer-local window options may not be recentv8.0.1836
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 #2336)
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/buffer.c b/src/buffer.c
index dd618337ef..e3cbdac1e8 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2895,8 +2895,23 @@ get_winopts(buf_T *buf)
#endif
wip = find_wininfo(buf, TRUE);
- if (wip != NULL && wip->wi_optset)
+ if (wip != NULL && wip->wi_win != NULL
+ && wip->wi_win != curwin && wip->wi_win->w_buffer == buf)
{
+ /* The buffer is currently displayed in the window: use the actual
+ * option values instead of the saved (possibly outdated) values. */
+ win_T *wp = wip->wi_win;
+
+ copy_winopt(&wp->w_onebuf_opt, &curwin->w_onebuf_opt);
+#ifdef FEAT_FOLDING
+ curwin->w_fold_manual = wp->w_fold_manual;
+ curwin->w_foldinvalid = TRUE;
+ cloneFoldGrowArray(&wp->w_folds, &curwin->w_folds);
+#endif
+ }
+ else if (wip != NULL && wip->wi_optset)
+ {
+ /* the buffer was displayed in the current window earlier */
copy_winopt(&wip->wi_opt, &curwin->w_onebuf_opt);
#ifdef FEAT_FOLDING
curwin->w_fold_manual = wip->wi_fold_manual;