aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/buffer.c
diff options
context:
space:
mode:
authorMarco Hinz <mh.codebro@gmail.com>2017-01-09 03:39:50 +0100
committerJames McCoy <jamessan@jamessan.com>2017-02-04 17:55:45 -0500
commit1836f3cb9b7e84ec5ed53ab0d3eb8496c95fe9e6 (patch)
treef28125201accc1ba7f6060add0d771d479830c3d /src/nvim/buffer.c
parente177226d51feb99e159773eebe6a773732fc89e9 (diff)
downloadrneovim-1836f3cb9b7e84ec5ed53ab0d3eb8496c95fe9e6.tar.gz
rneovim-1836f3cb9b7e84ec5ed53ab0d3eb8496c95fe9e6.tar.bz2
rneovim-1836f3cb9b7e84ec5ed53ab0d3eb8496c95fe9e6.zip
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. https://github.com/vim/vim/commit/19ff9bf454b7492be64dd87aaf0830fa7961871e
Diffstat (limited to 'src/nvim/buffer.c')
-rw-r--r--src/nvim/buffer.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 3b18bf5366..81dceacd37 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -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;