summaryrefslogtreecommitdiff
path: root/src/ex_cmds.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-09-03 16:29:04 +0200
committerBram Moolenaar <Bram@vim.org>2016-09-03 16:29:04 +0200
commit5a49789a9b1f6447aeafbbbdd5b235dd10c471d5 (patch)
tree611853ba4f58cc676cffdfdf622dad348372c269 /src/ex_cmds.c
parentdd905a2ae14bf2ee59a068f1c3acbca1ff0b7067 (diff)
downloadvim-git-5a49789a9b1f6447aeafbbbdd5b235dd10c471d5.tar.gz
patch 7.4.2312v7.4.2312
Problem: Crash when autocommand moves to another tab. (Dominique Pelle) Solution: When navigating to another window halfway the :edit command go back to the right window.
Diffstat (limited to 'src/ex_cmds.c')
-rw-r--r--src/ex_cmds.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 1deb8a368..61ab2ab12 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -3935,25 +3935,28 @@ do_ecmd(
auto_buf = TRUE;
else
{
+ win_T *the_curwin = curwin;
+
+ /* Set the w_closing flag to avoid that autocommands close the
+ * window. */
+ the_curwin->w_closing = TRUE;
+
if (curbuf == old_curbuf.br_buf)
#endif
buf_copy_options(buf, BCO_ENTER);
- /* close the link to the current buffer */
+ /* Close the link to the current buffer. This will set
+ * curwin->w_buffer to NULL. */
u_sync(FALSE);
close_buffer(oldwin, curbuf,
(flags & ECMD_HIDE) ? 0 : DOBUF_UNLOAD, FALSE);
#ifdef FEAT_AUTOCMD
- /* Autocommands may open a new window and leave oldwin open
- * which leads to crashes since the above call sets
- * oldwin->w_buffer to NULL. */
- if (curwin != oldwin && oldwin != aucmd_win
- && win_valid(oldwin) && oldwin->w_buffer == NULL)
- win_close(oldwin, FALSE);
+ the_curwin->w_closing = FALSE;
# ifdef FEAT_EVAL
- if (aborting()) /* autocmds may abort script processing */
+ /* autocmds may abort script processing */
+ if (aborting() && curwin->w_buffer != NULL)
{
vim_free(new_name);
goto theend;