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