Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bufhiddenを設定するとBufUnloadが2回実行される #912

Closed
norio13 opened this issue May 12, 2016 · 5 comments
Closed

bufhiddenを設定するとBufUnloadが2回実行される #912

norio13 opened this issue May 12, 2016 · 5 comments

Comments

@norio13
Copy link

norio13 commented May 12, 2016

質問・報告の内容

bufhiddenオプションにunload、deleteのどちらかが設定されたバッファに対して、
:bunload、:bdelete、:bwipeoutを実行するとBufUnloadが2回発火されました。

bufhiddenの値がhideとwipeまたは値なしの場合、上記3つのコマンドを実行してもBufUnloadは1回のみ発火します。

再現方法

Vim起動

vim -Nu NONE test.vim -c "so %"

test.vimの内容

new

" setlocal bufhidden=unload
setlocal bufhidden=delete

augroup mygroup
    autocmd!
    autocmd BufUnload <buffer> echo 'BufUnload'
augroup END

bunload
" bdelete
" bwipeout

Vimのバージョン

7.4.1830

OSの種類

  • Linux

OSのディストリ

Debian

OSのバージョン

8.4

@h-east
Copy link
Member

h-east commented May 14, 2016

これで様子を見てみて下さい。
make testはALL DONEなのは確認しました。

diff --git a/src/buffer.c b/src/buffer.c
index 9bc24bc..170e214 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -574,9 +574,12 @@ buf_freeall(buf_T *buf, int flags)
     int        is_curbuf = (buf == curbuf);

     buf->b_closing = TRUE;
-    apply_autocmds(EVENT_BUFUNLOAD, buf->b_fname, buf->b_fname, FALSE, buf);
-    if (!buf_valid(buf))       /* autocommands may delete the buffer */
-   return;
+    if (buf->b_ml.ml_mfp != NULL)
+    {
+   apply_autocmds(EVENT_BUFUNLOAD, buf->b_fname, buf->b_fname, FALSE, buf);
+   if (!buf_valid(buf))        /* autocommands may delete the buffer */
+       return;
+    }
     if ((flags & BFA_DEL) && buf->b_p_bl)
     {
    apply_autocmds(EVENT_BUFDELETE, buf->b_fname, buf->b_fname, FALSE, buf);

@mattn
Copy link
Member

mattn commented May 14, 2016

これ系多いすね。まだありそう。。。

@norio13
Copy link
Author

norio13 commented May 14, 2016

@h-east patch適用後、BufUnloadが2回発生しなくなりました。
迅速な対応に感謝致します。
ありがとうございます。

@h-east
Copy link
Member

h-east commented May 14, 2016

testを追加してvim_devに投げました。
https://groups.google.com/d/msg/vim_dev/xqWcI1YY9Qc/UTD83XpOCAAJ

@h-east h-east self-assigned this May 24, 2016
@h-east
Copy link
Member

h-east commented May 24, 2016

patch 7.4.1837 👍
vim/vim@c67e892

@norio13 issue登録ありがとうございました。

@h-east h-east closed this as completed May 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants