mirror of
https://github.com/neovim/neovim.git
synced 2025-09-13 06:48:17 +00:00
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)
46a53dfc29
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user