From a8d0062c67953d9e024a09d3d6daf062aefca887 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Mon, 8 Apr 2019 19:50:36 +0200 Subject: vim-patch:8.0.1763: :argedit does not reuse an empty unnamed buffer Problem: :argedit does not reuse an empty unnamed buffer. Solution: Add the BLN_CURBUF flag and fix all the side effects. (Christian Brabandt) https://github.com/vim/vim/commit/46a53dfc29689c6a0d80e3820e8b0a48dba6b6ec --- src/nvim/buffer.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/nvim/buffer.c') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 8d075dfeae..9a58529736 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1717,11 +1717,7 @@ buf_T * buflist_new(char_u *ffname, char_u *sfname, linenr_T lnum, int flags) * buffer.) */ buf = NULL; - if ((flags & BLN_CURBUF) - && curbuf != NULL - && curbuf->b_ffname == NULL - && curbuf->b_nwindows <= 1 - && (curbuf->b_ml.ml_mfp == NULL || BUFEMPTY())) { + if ((flags & BLN_CURBUF) && curbuf_reusable()) { buf = curbuf; /* It's like this buffer is deleted. Watch out for autocommands that * change curbuf! If that happens, allocate a new buffer anyway. */ @@ -1864,6 +1860,17 @@ buf_T * buflist_new(char_u *ffname, char_u *sfname, linenr_T lnum, int flags) return buf; } +/// Return true if the current buffer is empty, unnamed, unmodified and used in +/// only one window. That means it can be reused. +bool curbuf_reusable(void) +{ + return (curbuf != NULL + && curbuf->b_ffname == NULL + && curbuf->b_nwindows <= 1 + && (curbuf->b_ml.ml_mfp == NULL || BUFEMPTY()) + && !curbufIsChanged()); +} + /* * Free the memory for the options of a buffer. * If "free_p_ff" is true also free 'fileformat', 'buftype' and -- cgit From 7381c93e2c0e7aa20d29cbc3c6c45de71e22a258 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Mon, 8 Apr 2019 20:00:41 +0200 Subject: vim-patch:8.1.1134: buffer for quickfix window is reused for another file Problem: Buffer for quickfix window is reused for another file. Solution: Don't reuse the quickfx buffer. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/39803d82dbb215d2eea9fcd6cf2961b71515a438 --- src/nvim/buffer.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/buffer.c') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 9a58529736..703a89d31f 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1868,6 +1868,7 @@ bool curbuf_reusable(void) && curbuf->b_ffname == NULL && curbuf->b_nwindows <= 1 && (curbuf->b_ml.ml_mfp == NULL || BUFEMPTY()) + && !bt_quickfix(curbuf) && !curbufIsChanged()); } -- cgit