On Sa, 10 Aug 2013, Bram Moolenaar wrote: > Christian Brabandt wrote: > > > I had a problem with the NrrwRgn Plugin that seems to hang vim. > > Debugging it, I could make vim hang with this input: > > > > vim -N -c 'try|noa sview $VIMRUNTIME/doc/options.txt|finally |bw|endtry > > > > > > (It seems my .vimrc interferes, not sure which setting does). > > > > This hangs in buffer.c > > > > ,---- > > | * If the deleted buffer is the current one, close the current > > window > > | * (unless it's the only window). Repeat this so long as we end > > up in > > | * a window with this buffer (but try at most 10 times). > > | */ > > | while (buf == curbuf > > | # ifdef FEAT_AUTOCMD > > | && !(curwin->w_closing || curwin->w_buffer->b_closing) > > | # endif > > | && (firstwin != lastwin || first_tabpage->tp_next != > > NULL)) > > | win_close(curwin, FALSE); > > `---- > > > > And keeps on trying to close the window and doesn't succeed. So here is > > a patch, that tries at most 10 times. > > I wonder why the code doesn't do what the comment says. > > Why does it hang anyway?
Because an BufLeave autocommand aborted. I think the problem is originally caused by the :noa which prevents the execution of autocommands, while the bufwipe call executes bufleave autocommands, which expect a certain variable to be set by the BufEnter autocommand. Here is a simple commandline which reproduces the problem: vim -u NONE -N -c 'au BufLeave * :echo b:foobar ' -c 'try|noa sview $VIMRUNTIME/doc/options.txt|finally |bw|endtry' This causes win_close to return, and causes the while loop in do_buffer() to never break. So I think this patch is reasonable and should be applied to make sure, the while loop will break eventually. regards, Christian -- Ich höre auf mit meinen Witzen, außer ich höre in den nächsten Sekunden einen Lacher. -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.