To: vim-dev@vim.org Subject: Patch 6.3b.026 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.3b.026 Problem: When selecting "abort" at the ATTENTION prompt for a file that is already being edited Vim crashes. Solution: Don't abort creating a new buffer when we really need it. Files: src/buffer.c, src/vim.h *** ../vim-6.3b.025/src/buffer.c Sun May 16 22:38:46 2004 --- src/buffer.c Tue Jun 1 15:42:34 2004 *************** *** 693,700 **** swap_exists_action = SEA_NONE; /* don't want it again */ close_buffer(curwin, curbuf, DOBUF_UNLOAD); if (!buf_valid(old_curbuf) || old_curbuf == curbuf) ! old_curbuf = buflist_new(NULL, NULL, 1L, BLN_CURBUF | BLN_LISTED); ! enter_buffer(old_curbuf); } else if (swap_exists_action == SEA_RECOVER) { --- 693,703 ---- swap_exists_action = SEA_NONE; /* don't want it again */ close_buffer(curwin, curbuf, DOBUF_UNLOAD); if (!buf_valid(old_curbuf) || old_curbuf == curbuf) ! old_curbuf = buflist_new(NULL, NULL, 1L, ! BLN_CURBUF | BLN_LISTED | BLN_FORCE); ! if (old_curbuf != NULL) ! enter_buffer(old_curbuf); ! /* If "old_curbuf" is NULL we are in big trouble here... */ } else if (swap_exists_action == SEA_RECOVER) { *************** *** 1377,1382 **** --- 1380,1386 ---- * If (flags & BLN_CURBUF) is TRUE, may use current buffer. * If (flags & BLN_LISTED) is TRUE, add new buffer to buffer list. * If (flags & BLN_DUMMY) is TRUE, don't count it as a real buffer. + * If (flags & BLN_FORCE) is TRUE, don't abort on an error. * This is the ONLY way to create a new buffer. */ static int top_file_num = 1; /* highest file number */ *************** *** 1451,1457 **** if (buf == curbuf) apply_autocmds(EVENT_BUFWIPEOUT, NULL, NULL, FALSE, curbuf); # ifdef FEAT_EVAL ! if (aborting()) /* autocmds may abort script processing */ return NULL; # endif #endif --- 1455,1462 ---- if (buf == curbuf) apply_autocmds(EVENT_BUFWIPEOUT, NULL, NULL, FALSE, curbuf); # ifdef FEAT_EVAL ! /* autocmds may abort script processing */ ! if (!(flags & BLN_FORCE) && aborting()) return NULL; # endif #endif *************** *** 1504,1510 **** if (buf != curbuf) /* autocommands deleted the buffer! */ return NULL; #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) ! if (aborting()) /* autocmds may abort script processing */ return NULL; #endif /* buf->b_nwindows = 0; why was this here? */ --- 1509,1516 ---- if (buf != curbuf) /* autocommands deleted the buffer! */ return NULL; #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) ! /* autocmds may abort script processing */ ! if (!(flags & BLN_FORCE) && aborting()) return NULL; #endif /* buf->b_nwindows = 0; why was this here? */ *************** *** 1580,1586 **** if (flags & BLN_LISTED) apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, buf); # ifdef FEAT_EVAL ! if (aborting()) /* autocmds may abort script processing */ return NULL; # endif } --- 1586,1593 ---- if (flags & BLN_LISTED) apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, buf); # ifdef FEAT_EVAL ! /* autocmds may abort script processing */ ! if (!(flags & BLN_FORCE) && aborting()) return NULL; # endif } *** ../vim-6.3b.025/src/vim.h Sun May 16 22:38:45 2004 --- src/vim.h Tue Jun 1 15:22:43 2004 *************** *** 714,719 **** --- 714,720 ---- #define BLN_CURBUF 1 /* May re-use curbuf for new buffer */ #define BLN_LISTED 2 /* Put new buffer in buffer list */ #define BLN_DUMMY 4 /* Allocating dummy buffer */ + #define BLN_FORCE 8 /* Don't abort on error */ /* Values for in_cinkeys() */ #define KEY_OPEN_FORW 0x101 *** ../vim-6.3b.025/src/version.c Wed Jun 2 12:13:46 2004 --- src/version.c Wed Jun 2 17:40:40 2004 *************** *** 643,644 **** --- 643,646 ---- { /* Add new patch number below this line */ + /**/ + 26, /**/ -- I'm not familiar with this proof, but I'm aware of a significant following of toddlers who believe that peanut butter is the solution to all of life's problems... -- Tim Hammerquist /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///