|
|
22c937 |
To: vim_dev@googlegroups.com
|
|
|
22c937 |
Subject: Patch 7.4.140
|
|
|
22c937 |
Fcc: outbox
|
|
|
22c937 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
|
22c937 |
Mime-Version: 1.0
|
|
|
22c937 |
Content-Type: text/plain; charset=UTF-8
|
|
|
22c937 |
Content-Transfer-Encoding: 8bit
|
|
|
22c937 |
------------
|
|
|
22c937 |
|
|
|
22c937 |
Patch 7.4.140
|
|
|
22c937 |
Problem: Crash when wiping out buffer triggers autocommand that wipes out
|
|
|
22c937 |
only other buffer.
|
|
|
22c937 |
Solution: Do not delete the last buffer, make it empty. (Hirohito Higashi)
|
|
|
22c937 |
Files: src/buffer.c
|
|
|
22c937 |
|
|
|
22c937 |
|
|
|
22c937 |
*** ../vim-7.4.139/src/buffer.c 2013-11-06 05:26:08.000000000 +0100
|
|
|
22c937 |
--- src/buffer.c 2014-01-10 16:41:22.000000000 +0100
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 994,999 ****
|
|
|
22c937 |
--- 994,1043 ----
|
|
|
22c937 |
#if defined(FEAT_LISTCMDS) || defined(FEAT_PYTHON) \
|
|
|
22c937 |
|| defined(FEAT_PYTHON3) || defined(PROTO)
|
|
|
22c937 |
|
|
|
22c937 |
+ static int empty_curbuf __ARGS((int close_others, int forceit, int action));
|
|
|
22c937 |
+
|
|
|
22c937 |
+ /*
|
|
|
22c937 |
+ * Make the current buffer empty.
|
|
|
22c937 |
+ * Used when it is wiped out and it's the last buffer.
|
|
|
22c937 |
+ */
|
|
|
22c937 |
+ static int
|
|
|
22c937 |
+ empty_curbuf(close_others, forceit, action)
|
|
|
22c937 |
+ int close_others;
|
|
|
22c937 |
+ int forceit;
|
|
|
22c937 |
+ int action;
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ int retval;
|
|
|
22c937 |
+ buf_T *buf = curbuf;
|
|
|
22c937 |
+
|
|
|
22c937 |
+ if (action == DOBUF_UNLOAD)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ EMSG(_("E90: Cannot unload last buffer"));
|
|
|
22c937 |
+ return FAIL;
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+
|
|
|
22c937 |
+ if (close_others)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ /* Close any other windows on this buffer, then make it empty. */
|
|
|
22c937 |
+ #ifdef FEAT_WINDOWS
|
|
|
22c937 |
+ close_windows(buf, TRUE);
|
|
|
22c937 |
+ #endif
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+
|
|
|
22c937 |
+ setpcmark();
|
|
|
22c937 |
+ retval = do_ecmd(0, NULL, NULL, NULL, ECMD_ONE,
|
|
|
22c937 |
+ forceit ? ECMD_FORCEIT : 0, curwin);
|
|
|
22c937 |
+
|
|
|
22c937 |
+ /*
|
|
|
22c937 |
+ * do_ecmd() may create a new buffer, then we have to delete
|
|
|
22c937 |
+ * the old one. But do_ecmd() may have done that already, check
|
|
|
22c937 |
+ * if the buffer still exists.
|
|
|
22c937 |
+ */
|
|
|
22c937 |
+ if (buf != curbuf && buf_valid(buf) && buf->b_nwindows == 0)
|
|
|
22c937 |
+ close_buffer(NULL, buf, action, FALSE);
|
|
|
22c937 |
+ if (!close_others)
|
|
|
22c937 |
+ need_fileinfo = FALSE;
|
|
|
22c937 |
+ return retval;
|
|
|
22c937 |
+ }
|
|
|
22c937 |
/*
|
|
|
22c937 |
* Implementation of the commands for the buffer list.
|
|
|
22c937 |
*
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 1114,1120 ****
|
|
|
22c937 |
if (unload)
|
|
|
22c937 |
{
|
|
|
22c937 |
int forward;
|
|
|
22c937 |
- int retval;
|
|
|
22c937 |
|
|
|
22c937 |
/* When unloading or deleting a buffer that's already unloaded and
|
|
|
22c937 |
* unlisted: fail silently. */
|
|
|
22c937 |
--- 1158,1163 ----
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 1155,1184 ****
|
|
|
22c937 |
if (bp->b_p_bl && bp != buf)
|
|
|
22c937 |
break;
|
|
|
22c937 |
if (bp == NULL && buf == curbuf)
|
|
|
22c937 |
! {
|
|
|
22c937 |
! if (action == DOBUF_UNLOAD)
|
|
|
22c937 |
! {
|
|
|
22c937 |
! EMSG(_("E90: Cannot unload last buffer"));
|
|
|
22c937 |
! return FAIL;
|
|
|
22c937 |
! }
|
|
|
22c937 |
!
|
|
|
22c937 |
! /* Close any other windows on this buffer, then make it empty. */
|
|
|
22c937 |
! #ifdef FEAT_WINDOWS
|
|
|
22c937 |
! close_windows(buf, TRUE);
|
|
|
22c937 |
! #endif
|
|
|
22c937 |
! setpcmark();
|
|
|
22c937 |
! retval = do_ecmd(0, NULL, NULL, NULL, ECMD_ONE,
|
|
|
22c937 |
! forceit ? ECMD_FORCEIT : 0, curwin);
|
|
|
22c937 |
!
|
|
|
22c937 |
! /*
|
|
|
22c937 |
! * do_ecmd() may create a new buffer, then we have to delete
|
|
|
22c937 |
! * the old one. But do_ecmd() may have done that already, check
|
|
|
22c937 |
! * if the buffer still exists.
|
|
|
22c937 |
! */
|
|
|
22c937 |
! if (buf != curbuf && buf_valid(buf) && buf->b_nwindows == 0)
|
|
|
22c937 |
! close_buffer(NULL, buf, action, FALSE);
|
|
|
22c937 |
! return retval;
|
|
|
22c937 |
! }
|
|
|
22c937 |
|
|
|
22c937 |
#ifdef FEAT_WINDOWS
|
|
|
22c937 |
/*
|
|
|
22c937 |
--- 1198,1204 ----
|
|
|
22c937 |
if (bp->b_p_bl && bp != buf)
|
|
|
22c937 |
break;
|
|
|
22c937 |
if (bp == NULL && buf == curbuf)
|
|
|
22c937 |
! return empty_curbuf(TRUE, forceit, action);
|
|
|
22c937 |
|
|
|
22c937 |
#ifdef FEAT_WINDOWS
|
|
|
22c937 |
/*
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 1212,1218 ****
|
|
|
22c937 |
|
|
|
22c937 |
/*
|
|
|
22c937 |
* Deleting the current buffer: Need to find another buffer to go to.
|
|
|
22c937 |
! * There must be another, otherwise it would have been handled above.
|
|
|
22c937 |
* First use au_new_curbuf, if it is valid.
|
|
|
22c937 |
* Then prefer the buffer we most recently visited.
|
|
|
22c937 |
* Else try to find one that is loaded, after the current buffer,
|
|
|
22c937 |
--- 1232,1239 ----
|
|
|
22c937 |
|
|
|
22c937 |
/*
|
|
|
22c937 |
* Deleting the current buffer: Need to find another buffer to go to.
|
|
|
22c937 |
! * There should be another, otherwise it would have been handled
|
|
|
22c937 |
! * above. However, autocommands may have deleted all buffers.
|
|
|
22c937 |
* First use au_new_curbuf, if it is valid.
|
|
|
22c937 |
* Then prefer the buffer we most recently visited.
|
|
|
22c937 |
* Else try to find one that is loaded, after the current buffer,
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 1311,1316 ****
|
|
|
22c937 |
--- 1332,1344 ----
|
|
|
22c937 |
}
|
|
|
22c937 |
}
|
|
|
22c937 |
|
|
|
22c937 |
+ if (buf == NULL)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ /* Autocommands must have wiped out all other buffers. Only option
|
|
|
22c937 |
+ * now is to make the current buffer empty. */
|
|
|
22c937 |
+ return empty_curbuf(FALSE, forceit, action);
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+
|
|
|
22c937 |
/*
|
|
|
22c937 |
* make buf current buffer
|
|
|
22c937 |
*/
|
|
|
22c937 |
*** ../vim-7.4.139/src/version.c 2014-01-10 15:53:09.000000000 +0100
|
|
|
22c937 |
--- src/version.c 2014-01-10 16:36:03.000000000 +0100
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 740,741 ****
|
|
|
22c937 |
--- 740,743 ----
|
|
|
22c937 |
{ /* Add new patch number below this line */
|
|
|
22c937 |
+ /**/
|
|
|
22c937 |
+ 140,
|
|
|
22c937 |
/**/
|
|
|
22c937 |
|
|
|
22c937 |
--
|
|
|
22c937 |
hundred-and-one symptoms of being an internet addict:
|
|
|
22c937 |
133. You communicate with people on other continents more than you
|
|
|
22c937 |
do with your own neighbors.
|
|
|
22c937 |
|
|
|
22c937 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
|
22c937 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
|
22c937 |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
|
22c937 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|