Skip to content

Commit 9662f33

Browse files
zeertzjqchrisbra
authored andcommitted
patch 9.1.1599: :bnext doesn't go to unlisted help buffers
Problem: :bnext doesn't go to unlisted help buffers when cycling through help buffers (after 9.1.0557). Solution: Don't check if a help buffer is listed (zeertzjq). From <vim/vim#4478 (comment)>: > I think we should fix that, since once you get to a non-help buffer > all unlisted buffers are skipped, thus you won't encounter another > help buffer. This implies that cycling through help buffers should work even if help buffers are unlisted. Otherwise this part of :bnext isn't really useful, as :h makes help buffers unlisted by default. related: #4478 related: #15198 closes: #17913 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 9c4de84 commit 9662f33

3 files changed

Lines changed: 26 additions & 7 deletions

File tree

src/buffer.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,8 +1371,11 @@ do_buffer_ext(
13711371
}
13721372
else
13731373
{
1374+
int help_only = (flags & DOBUF_SKIPHELP) != 0 && buf->b_help;
1375+
13741376
bp = NULL;
1375-
while (count > 0 || (!unload && !buf->b_p_bl && bp != buf))
1377+
while (count > 0 || (bp != buf && !unload
1378+
&& !(help_only ? buf->b_help : buf->b_p_bl)))
13761379
{
13771380
// remember the buffer where we start, we come back there when all
13781381
// buffers are unlisted.
@@ -1390,14 +1393,17 @@ do_buffer_ext(
13901393
if (buf == NULL)
13911394
buf = lastbuf;
13921395
}
1396+
// Avoid non-help buffers if the starting point was a help buffer
1397+
// and vice-versa.
13931398
// Don't count unlisted buffers.
1394-
// Avoid non-help buffers if the starting point was a non-help buffer and
1395-
// vice-versa.
1396-
if (unload || (buf->b_p_bl
1397-
&& ((flags & DOBUF_SKIPHELP) == 0 || buf->b_help == bp->b_help)))
1399+
if (unload
1400+
|| (help_only
1401+
? buf->b_help
1402+
: (buf->b_p_bl && ((flags & DOBUF_SKIPHELP) == 0
1403+
|| !buf->b_help))))
13981404
{
1399-
--count;
1400-
bp = NULL; // use this buffer as new starting point
1405+
--count;
1406+
bp = NULL; // use this buffer as new starting point
14011407
}
14021408
if (bp == buf)
14031409
{

src/testdir/test_buffer.vim

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,17 @@ func Test_bnext_bprev_help()
167167
b XHelp1
168168
blast | call assert_equal(b4, bufnr())
169169

170+
" Cycling through help buffers works even if they aren't listed.
171+
b XHelp1
172+
setlocal nobuflisted
173+
bnext | call assert_equal(b3, bufnr())
174+
bnext | call assert_equal(b1, bufnr())
175+
bprev | call assert_equal(b3, bufnr())
176+
setlocal nobuflisted
177+
bprev | call assert_equal(b1, bufnr())
178+
bprev | call assert_equal(b3, bufnr())
179+
bnext | call assert_equal(b1, bufnr())
180+
170181
%bwipe!
171182
endfunc
172183

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,8 @@ static char *(features[]) =
719719

720720
static int included_patches[] =
721721
{ /* Add new patch number below this line */
722+
/**/
723+
1599,
722724
/**/
723725
1598,
724726
/**/

0 commit comments

Comments
 (0)