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