To: vim-dev@vim.org Subject: Patch 6.0.221 Fcc: outbox From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.0.221 Problem: When using ":bdel" and all other buffers are unloaded the lowest numbered buffer is jumped to instead of the most recent one. (Dave Cecil) Solution: Prefer an unloaded buffer from the jumplist. Files: src/buffer.c *** ../vim60.220/src/buffer.c Mon Feb 11 17:46:17 2002 --- src/buffer.c Tue Feb 12 10:06:46 2002 *************** *** 951,957 **** * then before the current buffer. * Finally use any buffer. */ ! buf = NULL; #ifdef FEAT_AUTOCMD if (au_new_curbuf != NULL && buf_valid(au_new_curbuf)) buf = au_new_curbuf; --- 951,958 ---- * then before the current buffer. * Finally use any buffer. */ ! buf = NULL; /* selected buffer */ ! bp = NULL; /* used when no loaded buffer found */ #ifdef FEAT_AUTOCMD if (au_new_curbuf != NULL && buf_valid(au_new_curbuf)) buf = au_new_curbuf; *************** *** 972,983 **** while (jumpidx != curwin->w_jumplistidx) { buf = buflist_findnr(curwin->w_jumplist[jumpidx].fmark.fnum); - if (buf == curbuf - || (buf != NULL - && (buf->b_ml.ml_mfp == NULL || !buf->b_p_bl))) - buf = NULL; /* Must be open, listed and not current */ - /* found a valid buffer: stop searching */ if (buf != NULL) break; /* advance to older entry in jump list */ if (!jumpidx && curwin->w_jumplistidx == curwin->w_jumplistlen) --- 973,991 ---- while (jumpidx != curwin->w_jumplistidx) { buf = buflist_findnr(curwin->w_jumplist[jumpidx].fmark.fnum); if (buf != NULL) + { + if (buf == curbuf || !buf->b_p_bl) + buf = NULL; /* skip current and unlisted bufs */ + else if (buf->b_ml.ml_mfp == NULL) + { + /* skip unloaded buf, but may keep it for later */ + if (bp == NULL) + bp = buf; + buf = NULL; + } + } + if (buf != NULL) /* found a valid buffer: stop searching */ break; /* advance to older entry in jump list */ if (!jumpidx && curwin->w_jumplistidx == curwin->w_jumplistlen) *************** *** 1005,1020 **** continue; } /* in non-help buffer, try to skip help buffers, and vv */ ! if (buf->b_ml.ml_mfp != NULL ! && buf->b_help == curbuf->b_help ! && buf->b_p_bl) ! break; if (forward) buf = buf->b_next; else buf = buf->b_prev; } } if (buf == NULL) /* No loaded buffer, find listed one */ { for (buf = firstbuf; buf != NULL; buf = buf->b_next) --- 1013,1033 ---- continue; } /* in non-help buffer, try to skip help buffers, and vv */ ! if (buf->b_help == curbuf->b_help && buf->b_p_bl) ! { ! if (buf->b_ml.ml_mfp != NULL) /* found loaded buffer */ ! break; ! if (bp == NULL) /* remember unloaded buf for later */ ! bp = buf; ! } if (forward) buf = buf->b_next; else buf = buf->b_prev; } } + if (buf == NULL) /* No loaded buffer, use unloaded one */ + buf = bp; if (buf == NULL) /* No loaded buffer, find listed one */ { for (buf = firstbuf; buf != NULL; buf = buf->b_next) *** ../vim60.220/src/version.c Mon Feb 11 22:00:42 2002 --- src/version.c Tue Feb 12 10:09:02 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 221, /**/ -- ARTHUR: Be quiet! DENNIS: Well you can't expect to wield supreme executive power just 'cause some watery tart threw a sword at you! ARTHUR: Shut up! DENNIS: I mean, if I went around sayin' I was an empereror just because some moistened bint had lobbed a scimitar at me they'd put me away! The Quest for the Holy Grail (Monty Python) /// 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 ///