aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/buffer.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-08-08 15:33:23 +0800
committerGitHub <noreply@github.com>2024-08-08 15:33:23 +0800
commit2f1ea1133a47df782925ac88bc3cecb649fb0b23 (patch)
treeeeb9960c26113f3cde357b9111445f684f7de274 /src/nvim/buffer.c
parentf35d5afbf1bae81896d4b959c7d99cf50e0c306f (diff)
parent94cc29392776df268e87e2344cf1b3bc466066da (diff)
downloadrneovim-2f1ea1133a47df782925ac88bc3cecb649fb0b23.tar.gz
rneovim-2f1ea1133a47df782925ac88bc3cecb649fb0b23.tar.bz2
rneovim-2f1ea1133a47df782925ac88bc3cecb649fb0b23.zip
Merge pull request #30008 from zeertzjq/vim-8.2.3476
vim-patch:8.2.{3476,3477}
Diffstat (limited to 'src/nvim/buffer.c')
-rw-r--r--src/nvim/buffer.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 0c301bd5e2..ab648708fc 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -2959,7 +2959,17 @@ int setfname(buf_T *buf, char *ffname_arg, char *sfname_arg, bool message)
obuf = buflist_findname_file_id(ffname, &file_id, file_id_valid);
}
if (obuf != NULL && obuf != buf) {
- if (obuf->b_ml.ml_mfp != NULL) { // it's loaded, fail
+ bool in_use = false;
+
+ // during startup a window may use a buffer that is not loaded yet
+ FOR_ALL_TAB_WINDOWS(tab, win) {
+ if (win->w_buffer == obuf) {
+ in_use = true;
+ }
+ }
+
+ // it's loaded or used in a window, fail
+ if (obuf->b_ml.ml_mfp != NULL || in_use) {
if (message) {
emsg(_("E95: Buffer with this name already exists"));
}