mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
Don't execute some autocommands when v:dying is 2 or more.
This commit is contained in:
@@ -401,6 +401,8 @@ BufUnload Before unloading a buffer. This is when the
|
|||||||
buffer being unloaded "<afile>".
|
buffer being unloaded "<afile>".
|
||||||
Don't change to another buffer, it will cause
|
Don't change to another buffer, it will cause
|
||||||
problems.
|
problems.
|
||||||
|
When exiting and v:dying is 2 or more this
|
||||||
|
event is not triggered.
|
||||||
*BufWinEnter*
|
*BufWinEnter*
|
||||||
BufWinEnter After a buffer is displayed in a window. This
|
BufWinEnter After a buffer is displayed in a window. This
|
||||||
can be when the buffer is loaded (after
|
can be when the buffer is loaded (after
|
||||||
@@ -422,6 +424,8 @@ BufWinLeave Before a buffer is removed from a window.
|
|||||||
NOTE: When this autocommand is executed, the
|
NOTE: When this autocommand is executed, the
|
||||||
current buffer "%" may be different from the
|
current buffer "%" may be different from the
|
||||||
buffer being unloaded "<afile>".
|
buffer being unloaded "<afile>".
|
||||||
|
When exiting and v:dying is 2 or more this
|
||||||
|
event is not triggered.
|
||||||
*BufWipeout*
|
*BufWipeout*
|
||||||
BufWipeout Before completely deleting a buffer. The
|
BufWipeout Before completely deleting a buffer. The
|
||||||
BufUnload and BufDelete events may be called
|
BufUnload and BufDelete events may be called
|
||||||
@@ -799,6 +803,8 @@ VimLeave Before exiting Vim, just after writing the
|
|||||||
.viminfo file. Executed only once, like
|
.viminfo file. Executed only once, like
|
||||||
VimLeavePre.
|
VimLeavePre.
|
||||||
To detect an abnormal exit use |v:dying|.
|
To detect an abnormal exit use |v:dying|.
|
||||||
|
When v:dying is 2 or more this event is not
|
||||||
|
triggered.
|
||||||
*VimLeavePre*
|
*VimLeavePre*
|
||||||
VimLeavePre Before exiting Vim, just before writing the
|
VimLeavePre Before exiting Vim, just before writing the
|
||||||
.viminfo file. This is executed only once,
|
.viminfo file. This is executed only once,
|
||||||
@@ -807,6 +813,8 @@ VimLeavePre Before exiting Vim, just before writing the
|
|||||||
Mostly useful with a "*" pattern. >
|
Mostly useful with a "*" pattern. >
|
||||||
:autocmd VimLeavePre * call CleanupStuff()
|
:autocmd VimLeavePre * call CleanupStuff()
|
||||||
< To detect an abnormal exit use |v:dying|.
|
< To detect an abnormal exit use |v:dying|.
|
||||||
|
When v:dying is 2 or more this event is not
|
||||||
|
triggered.
|
||||||
*VimResized*
|
*VimResized*
|
||||||
VimResized After the Vim window was resized, thus 'lines'
|
VimResized After the Vim window was resized, thus 'lines'
|
||||||
and/or 'columns' changed. Not when starting
|
and/or 'columns' changed. Not when starting
|
||||||
|
@@ -1348,7 +1348,9 @@ v:dying Normally zero. When a deadly signal is caught it's set to
|
|||||||
terminate normally. {only works on Unix}
|
terminate normally. {only works on Unix}
|
||||||
Example: >
|
Example: >
|
||||||
:au VimLeave * if v:dying | echo "\nAAAAaaaarrrggghhhh!!!\n" | endif
|
:au VimLeave * if v:dying | echo "\nAAAAaaaarrrggghhhh!!!\n" | endif
|
||||||
<
|
< Note: if another deadly signal is caught when v:dying is one,
|
||||||
|
VimLeave autocommands will not be executed.
|
||||||
|
|
||||||
*v:errmsg* *errmsg-variable*
|
*v:errmsg* *errmsg-variable*
|
||||||
v:errmsg Last given error message. It's allowed to set this variable.
|
v:errmsg Last given error message. It's allowed to set this variable.
|
||||||
Example: >
|
Example: >
|
||||||
|
@@ -30,9 +30,6 @@ be worked on, but only if you sponsor Vim development. See |sponsor|.
|
|||||||
*known-bugs*
|
*known-bugs*
|
||||||
-------------------- Known bugs and current work -----------------------
|
-------------------- Known bugs and current work -----------------------
|
||||||
|
|
||||||
When Vim crashes it may run out of stack while executing autocommands. Patch
|
|
||||||
to not run autocommands when leaving Vim? (James Vega, 2010 May 23)
|
|
||||||
|
|
||||||
Patch for invalid mem access in completion. (Dominique Pelle, 2010 May 26)
|
Patch for invalid mem access in completion. (Dominique Pelle, 2010 May 26)
|
||||||
|
|
||||||
Invalid memory access when deleting funcref variable. Patch by Lech Lorens,
|
Invalid memory access when deleting funcref variable. Patch by Lech Lorens,
|
||||||
|
@@ -7166,6 +7166,10 @@ don't save what you see. This could result in work being lost. Now the text
|
|||||||
after recovery is compared to the original file contents. When they differ
|
after recovery is compared to the original file contents. When they differ
|
||||||
the buffer is marked as modified.
|
the buffer is marked as modified.
|
||||||
|
|
||||||
|
When Vim is exiting because of a deadly signal, when v:dying is 2 or more,
|
||||||
|
VimLeavePre, VimLeave, BufWinLeave and BufUnload autocommands are not
|
||||||
|
executed.
|
||||||
|
|
||||||
|
|
||||||
Added *added-7.3*
|
Added *added-7.3*
|
||||||
-----
|
-----
|
||||||
|
57
src/main.c
57
src/main.c
@@ -1276,40 +1276,44 @@ getout(exitval)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FEAT_AUTOCMD
|
#ifdef FEAT_AUTOCMD
|
||||||
/* Trigger BufWinLeave for all windows, but only once per buffer. */
|
if (get_vim_var_nr(VV_DYING) <= 1)
|
||||||
# if defined FEAT_WINDOWS
|
|
||||||
for (tp = first_tabpage; tp != NULL; tp = next_tp)
|
|
||||||
{
|
{
|
||||||
next_tp = tp->tp_next;
|
/* Trigger BufWinLeave for all windows, but only once per buffer. */
|
||||||
for (wp = (tp == curtab)
|
# if defined FEAT_WINDOWS
|
||||||
? firstwin : tp->tp_firstwin; wp != NULL; wp = wp->w_next)
|
for (tp = first_tabpage; tp != NULL; tp = next_tp)
|
||||||
{
|
{
|
||||||
buf = wp->w_buffer;
|
next_tp = tp->tp_next;
|
||||||
if (buf->b_changedtick != -1)
|
for (wp = (tp == curtab)
|
||||||
|
? firstwin : tp->tp_firstwin; wp != NULL; wp = wp->w_next)
|
||||||
{
|
{
|
||||||
apply_autocmds(EVENT_BUFWINLEAVE, buf->b_fname, buf->b_fname,
|
buf = wp->w_buffer;
|
||||||
FALSE, buf);
|
if (buf->b_changedtick != -1)
|
||||||
buf->b_changedtick = -1; /* note that we did it already */
|
{
|
||||||
/* start all over, autocommands may mess up the lists */
|
apply_autocmds(EVENT_BUFWINLEAVE, buf->b_fname,
|
||||||
next_tp = first_tabpage;
|
buf->b_fname, FALSE, buf);
|
||||||
break;
|
buf->b_changedtick = -1; /* note that we did it already */
|
||||||
|
/* start all over, autocommands may mess up the lists */
|
||||||
|
next_tp = first_tabpage;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
# else
|
# else
|
||||||
apply_autocmds(EVENT_BUFWINLEAVE, curbuf, curbuf->b_fname, FALSE, curbuf);
|
apply_autocmds(EVENT_BUFWINLEAVE, curbuf, curbuf->b_fname,
|
||||||
|
FALSE, curbuf);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
/* Trigger BufUnload for buffers that are loaded */
|
/* Trigger BufUnload for buffers that are loaded */
|
||||||
for (buf = firstbuf; buf != NULL; buf = buf->b_next)
|
for (buf = firstbuf; buf != NULL; buf = buf->b_next)
|
||||||
if (buf->b_ml.ml_mfp != NULL)
|
if (buf->b_ml.ml_mfp != NULL)
|
||||||
{
|
{
|
||||||
apply_autocmds(EVENT_BUFUNLOAD, buf->b_fname, buf->b_fname,
|
apply_autocmds(EVENT_BUFUNLOAD, buf->b_fname, buf->b_fname,
|
||||||
FALSE, buf);
|
FALSE, buf);
|
||||||
if (!buf_valid(buf)) /* autocmd may delete the buffer */
|
if (!buf_valid(buf)) /* autocmd may delete the buffer */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
apply_autocmds(EVENT_VIMLEAVEPRE, NULL, NULL, FALSE, curbuf);
|
apply_autocmds(EVENT_VIMLEAVEPRE, NULL, NULL, FALSE, curbuf);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FEAT_VIMINFO
|
#ifdef FEAT_VIMINFO
|
||||||
@@ -1319,7 +1323,8 @@ getout(exitval)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FEAT_AUTOCMD
|
#ifdef FEAT_AUTOCMD
|
||||||
apply_autocmds(EVENT_VIMLEAVE, NULL, NULL, FALSE, curbuf);
|
if (get_vim_var_nr(VV_DYING) <= 1)
|
||||||
|
apply_autocmds(EVENT_VIMLEAVE, NULL, NULL, FALSE, curbuf);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FEAT_PROFILE
|
#ifdef FEAT_PROFILE
|
||||||
|
Reference in New Issue
Block a user