vim-patch:7.4.2021

Problem:  Still too many buf_valid() calls.
Solution: Make au_new_curbuf a bufref.  Use bufref_valid() in more places.

19ff9bf454
This commit is contained in:
Marco Hinz
2017-01-09 03:39:50 +01:00
committed by James McCoy
parent e177226d51
commit 1836f3cb9b
4 changed files with 66 additions and 53 deletions

View File

@@ -1114,21 +1114,19 @@ do_buffer (
return OK;
}
/*
* Deleting the current buffer: Need to find another buffer to go to.
* There should be another, otherwise it would have been handled
* above. However, autocommands may have deleted all buffers.
* First use au_new_curbuf, if it is valid.
* Then prefer the buffer we most recently visited.
* Else try to find one that is loaded, after the current buffer,
* then before the current buffer.
* Finally use any buffer.
*/
buf = NULL; /* selected buffer */
bp = NULL; /* used when no loaded buffer found */
if (au_new_curbuf != NULL && buf_valid(au_new_curbuf))
buf = au_new_curbuf;
else if (curwin->w_jumplistlen > 0) {
// Deleting the current buffer: Need to find another buffer to go to.
// There should be another, otherwise it would have been handled
// above. However, autocommands may have deleted all buffers.
// First use au_new_curbuf.br_buf, if it is valid.
// Then prefer the buffer we most recently visited.
// Else try to find one that is loaded, after the current buffer,
// then before the current buffer.
// Finally use any buffer.
buf = NULL; // Selected buffer.
bp = NULL; // Used when no loaded buffer found.
if (au_new_curbuf.br_buf != NULL && bufref_valid(&au_new_curbuf)) {
buf = au_new_curbuf.br_buf;
} else if (curwin->w_jumplistlen > 0) {
int jumpidx;
jumpidx = curwin->w_jumplistidx - 1;