mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 09:44:31 +00:00 
			
		
		
		
	vim-patch:9.1.1599: :bnext doesn't go to unlisted help buffers (#35216)
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 <https://github.com/vim/vim/issues/4478#issuecomment-498831057>:
> 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: vim/vim#4478
related: vim/vim#15198
closes: vim/vim#17913
9662f33480
(cherry picked from commit 53ac2ad20a)
			
			
This commit is contained in:
		
				
					committed by
					
						
						github-actions[bot]
					
				
			
			
				
	
			
			
			
						parent
						
							f4b4c27a35
						
					
				
				
					commit
					54c2ea142a
				
			@@ -1255,8 +1255,11 @@ static int do_buffer_ext(int action, int start, int dir, int count, int flags)
 | 
				
			|||||||
      buf = buf->b_next;
 | 
					      buf = buf->b_next;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
 | 
					    const bool help_only = (flags & DOBUF_SKIPHELP) != 0 && buf->b_help;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    bp = NULL;
 | 
					    bp = NULL;
 | 
				
			||||||
    while (count > 0 || (!unload && !buf->b_p_bl && bp != buf)) {
 | 
					    while (count > 0 || (bp != buf && !unload
 | 
				
			||||||
 | 
					                         && !(help_only ? buf->b_help : buf->b_p_bl))) {
 | 
				
			||||||
      // remember the buffer where we start, we come back there when all
 | 
					      // remember the buffer where we start, we come back there when all
 | 
				
			||||||
      // buffers are unlisted.
 | 
					      // buffers are unlisted.
 | 
				
			||||||
      if (bp == NULL) {
 | 
					      if (bp == NULL) {
 | 
				
			||||||
@@ -1264,12 +1267,13 @@ static int do_buffer_ext(int action, int start, int dir, int count, int flags)
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
      buf = dir == FORWARD ? (buf->b_next != NULL ? buf->b_next : firstbuf)
 | 
					      buf = dir == FORWARD ? (buf->b_next != NULL ? buf->b_next : firstbuf)
 | 
				
			||||||
                           : (buf->b_prev != NULL ? buf->b_prev : lastbuf);
 | 
					                           : (buf->b_prev != NULL ? buf->b_prev : lastbuf);
 | 
				
			||||||
 | 
					      // Avoid non-help buffers if the starting point was a help buffer
 | 
				
			||||||
 | 
					      // and vice-versa.
 | 
				
			||||||
      // Don't count unlisted buffers.
 | 
					      // Don't count unlisted buffers.
 | 
				
			||||||
      // Avoid non-help buffers if the starting point was a non-help buffer and
 | 
					 | 
				
			||||||
      // vice-versa.
 | 
					 | 
				
			||||||
      if (unload
 | 
					      if (unload
 | 
				
			||||||
          || (buf->b_p_bl
 | 
					          || (help_only
 | 
				
			||||||
              && ((flags & DOBUF_SKIPHELP) == 0 || buf->b_help == bp->b_help))) {
 | 
					              ? buf->b_help
 | 
				
			||||||
 | 
					              : (buf->b_p_bl && ((flags & DOBUF_SKIPHELP) == 0 || !buf->b_help)))) {
 | 
				
			||||||
        count--;
 | 
					        count--;
 | 
				
			||||||
        bp = NULL;              // use this buffer as new starting point
 | 
					        bp = NULL;              // use this buffer as new starting point
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -169,6 +169,17 @@ func Test_bnext_bprev_help()
 | 
				
			|||||||
  b XHelp1
 | 
					  b XHelp1
 | 
				
			||||||
  blast   | call assert_equal(b4, bufnr())
 | 
					  blast   | call assert_equal(b4, bufnr())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  " Cycling through help buffers works even if they aren't listed.
 | 
				
			||||||
 | 
					  b XHelp1
 | 
				
			||||||
 | 
					  setlocal nobuflisted
 | 
				
			||||||
 | 
					  bnext | call assert_equal(b3, bufnr())
 | 
				
			||||||
 | 
					  bnext | call assert_equal(b1, bufnr())
 | 
				
			||||||
 | 
					  bprev | call assert_equal(b3, bufnr())
 | 
				
			||||||
 | 
					  setlocal nobuflisted
 | 
				
			||||||
 | 
					  bprev | call assert_equal(b1, bufnr())
 | 
				
			||||||
 | 
					  bprev | call assert_equal(b3, bufnr())
 | 
				
			||||||
 | 
					  bnext | call assert_equal(b1, bufnr())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  %bwipe!
 | 
					  %bwipe!
 | 
				
			||||||
endfunc
 | 
					endfunc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user