diff options
author | Grzegorz Milka <grzegorzmilka@gmail.com> | 2016-10-18 02:02:47 +0200 |
---|---|---|
committer | Grzegorz Milka <grzegorzmilka@gmail.com> | 2016-10-23 00:41:45 +0200 |
commit | 9755a2ffd5727c7fc0576e60a21368618978c504 (patch) | |
tree | 573e946bce3ebb9380e1a9e2d7ed461341ea16ea /src/nvim/ex_cmds.c | |
parent | c5c8a821341b71ae29786c97df7930a9581f7ab7 (diff) | |
download | rneovim-9755a2ffd5727c7fc0576e60a21368618978c504.tar.gz rneovim-9755a2ffd5727c7fc0576e60a21368618978c504.tar.bz2 rneovim-9755a2ffd5727c7fc0576e60a21368618978c504.zip |
vim-patch:7.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.
https://github.com/vim/vim/commit/5a49789a9b1f6447aeafbbbdd5b235dd10c471d5
Diffstat (limited to 'src/nvim/ex_cmds.c')
-rw-r--r-- | src/nvim/ex_cmds.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 6205daf0cb..79ee69bb56 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -2253,25 +2253,23 @@ do_ecmd ( if (buf == curbuf) /* already in new buffer */ 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) 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) || curbuf->terminal ? 0 : DOBUF_UNLOAD, FALSE); - /* 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)) { - assert(oldwin); - if (oldwin->w_buffer == NULL) { - win_close(oldwin, FALSE); - } - } + the_curwin->w_closing = FALSE; - if (aborting()) { /* autocmds may abort script processing */ + // autocmds may abort script processing + if (aborting() && curwin->w_buffer != NULL) { xfree(new_name); goto theend; } |