patch 9.1.0557: moving in the buffer list doesn't work as documented
Problem: moving in the buffer list doesn't work as documented
(SenileFelineS)
Solution: Skip non-help buffers, when run from normal buffers, else
only move from help buffers to the next help buffer (LemonBoy)
As explained in the help section for :bnext and :bprev the commands
should jump from help buffers to help buffers (and from regular ones to
regular ones).
fixes: #4478
closes: #15198
Signed-off-by: LemonBoy <thatlemon@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/buffer.c b/src/buffer.c
index 82957f9..447ce76 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -50,6 +50,7 @@
static void free_buffer_stuff(buf_T *buf, int free_options);
static int bt_nofileread(buf_T *buf);
static void no_write_message_buf(buf_T *buf);
+static int do_buffer_ext(int action, int start, int dir, int count, int flags);
#ifdef UNIX
# define dev_T dev_t
@@ -1106,13 +1107,30 @@
{
bufref_T old_curbuf;
int save_sea = swap_exists_action;
+ int skip_help_buf;
+
+ switch (eap->cmdidx)
+ {
+ case CMD_bnext:
+ case CMD_sbnext:
+ case CMD_bNext:
+ case CMD_bprevious:
+ case CMD_sbNext:
+ case CMD_sbprevious:
+ skip_help_buf = TRUE;
+ break;
+ default:
+ skip_help_buf = FALSE;
+ break;
+ }
set_bufref(&old_curbuf, curbuf);
if (swap_exists_action == SEA_NONE)
swap_exists_action = SEA_DIALOG;
- (void)do_buffer(*eap->cmd == 's' ? DOBUF_SPLIT : DOBUF_GOTO,
- start, dir, count, eap->forceit);
+ (void)do_buffer_ext(*eap->cmd == 's' ? DOBUF_SPLIT : DOBUF_GOTO, start, dir, count,
+ (eap->forceit ? DOBUF_FORCEIT : 0) |
+ (skip_help_buf ? DOBUF_SKIPHELP : 0));
if (swap_exists_action == SEA_QUIT && *eap->cmd == 's')
{
#if defined(FEAT_EVAL)
@@ -1343,8 +1361,11 @@
if (buf == NULL)
buf = lastbuf;
}
- // don't count unlisted buffers
- if (unload || buf->b_p_bl)
+ // Don't count unlisted buffers.
+ // Avoid non-help buffers if the starting point was a non-help buffer and
+ // vice-versa.
+ if (unload || (buf->b_p_bl
+ && ((flags & DOBUF_SKIPHELP) == 0 || buf->b_help == bp->b_help)))
{
--count;
bp = NULL; // use this buffer as new starting point