To: vim-dev@vim.org Subject: Patch 6.0.217 Fcc: outbox From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.0.217 Problem: When getting help from a help file that was used before, an empty unlisted buffer remains in the buffer list. (Eric Long) Solution: Wipe out the buffer used to do the tag jump from. Files: src/buffer.c, src/ex_cmds.c, src/proto/buffer.pro *** ../vim60.216/src/buffer.c Mon Feb 11 14:09:33 2002 --- src/buffer.c Mon Feb 11 17:39:50 2002 *************** *** 1885,1890 **** --- 1885,1891 ---- /* * Get name of file 'n' in the buffer list. + * When the file has no name an empty string is returned. * home_replace() is used to shorten the file name (used for marks). * Returns a pointer to allocated memory, of NULL when failed. */ *************** *** 4545,4556 **** #endif if (curbuf != newbuf) /* safety check */ ! { ! /* Don't increase the last buffer number. */ ! if (newbuf->b_fnum == top_file_num - 1) ! --top_file_num; ! close_buffer(NULL, newbuf, DOBUF_WIPE); ! } return differ; } --- 4546,4566 ---- #endif if (curbuf != newbuf) /* safety check */ ! wipe_buffer(newbuf); return differ; + } + + /* + * Wipe out a buffer and decrement the last buffer number if it was used for + * this buffer. Call this to wipe out a temp buffer that does not contain any + * marks. + */ + void + wipe_buffer(buf) + buf_T *buf; + { + if (buf->b_fnum == top_file_num - 1) + --top_file_num; + close_buffer(NULL, buf, DOBUF_WIPE); } *** ../vim60.216/src/ex_cmds.c Mon Feb 4 15:18:30 2002 --- src/ex_cmds.c Mon Feb 11 17:40:17 2002 *************** *** 4376,4381 **** --- 4376,4383 ---- char_u **matches; int need_free = FALSE; char_u *p; + int empty_fnum = 0; + buf_T *buf; if (eap != NULL) { *************** *** 4442,4448 **** #endif { /* ! * There is no help buffer yet. * Try to open the file specified by the "helpfile" option. */ if ((helpfd = mch_fopen((char *)p_hf, READBIN)) == NULL) --- 4444,4450 ---- #endif { /* ! * There is no help window yet. * Try to open the file specified by the "helpfile" option. */ if ((helpfd = mch_fopen((char *)p_hf, READBIN)) == NULL) *************** *** 4479,4484 **** --- 4481,4487 ---- */ (void)do_ecmd(0, NULL, NULL, NULL, ECMD_LASTL, ECMD_HIDE + ECMD_SET_HELP); + empty_fnum = curbuf->b_fnum; } } *************** *** 4491,4496 **** --- 4494,4507 ---- need_free = FALSE; } do_tag(arg, DT_HELP, 1, FALSE, TRUE); + + /* Delete the empty buffer if we're not using it. */ + if (empty_fnum != 0 && curbuf->b_fnum != empty_fnum) + { + buf = buflist_findnr(empty_fnum); + if (buf != NULL) + wipe_buffer(buf); + } /* * Always set these options after jumping to a help tag, because the user *** ../vim60.216/src/proto/buffer.pro Tue Sep 25 21:49:10 2001 --- src/proto/buffer.pro Mon Feb 11 17:40:36 2002 *************** *** 60,63 **** --- 60,64 ---- void sign_mark_adjust __ARGS((linenr_T line1, linenr_T line2, long amount, long amount_after)); void set_buflisted __ARGS((int on)); int buf_contents_changed __ARGS((buf_T *buf)); + void wipe_buffer __ARGS((buf_T *buf)); /* vim: set ft=c : */ *** ../vim60.216/src/version.c Mon Feb 11 16:56:42 2002 --- src/version.c Mon Feb 11 17:43:43 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 217, /**/ -- `When any government, or any church for that matter, undertakes to say to its subjects, "This you may not read, this you must not see, this you are forbidden to know," the end result is tyranny and oppression no matter how holy the motives' -- Robert A Heinlein, "If this goes on --" /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ ((( Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim ))) \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///