Skip to content

Commit

Permalink
patch 9.0.0789: dummy buffer ends up in a window
Browse files Browse the repository at this point in the history
Problem:    Dummy buffer ends up in a window.
Solution:   Disallow navigating to a dummy buffer.
  • Loading branch information
brammool committed Oct 18, 2022
1 parent 61c4b04 commit 8f3c3c6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/buffer.c
Expand Up @@ -1351,6 +1351,13 @@ do_buffer_ext(
if ((flags & DOBUF_NOPOPUP) && bt_popup(buf) && !bt_terminal(buf))
return OK;
#endif
if ((action == DOBUF_GOTO || action == DOBUF_SPLIT)
&& (buf->b_flags & BF_DUMMY))
{
// disallow navigating to the dummy buffer
semsg(_(e_buffer_nr_does_not_exist), count);
return FAIL;
}

#ifdef FEAT_GUI
need_mouse_correct = TRUE;
Expand Down
20 changes: 20 additions & 0 deletions src/testdir/test_autocmd.vim
Expand Up @@ -3857,4 +3857,24 @@ func Test_autocmd_delete()
call assert_true(autocmd_delete([test_null_dict()]))
endfunc

func Test_autocmd_split_dummy()
" Autocommand trying to split a window containing a dummy buffer.
auto BufReadPre * exe "sbuf " .. expand("<abuf>")
" Avoid the "W11" prompt
au FileChangedShell * let v:fcs_choice = 'reload'
func Xautocmd_changelist()
cal writefile(['Xtestfile2:4:4'], 'Xerr')
edit Xerr
lex 'Xtestfile2:4:4'
endfunc
call Xautocmd_changelist()
call assert_fails('call Xautocmd_changelist()', 'E86:')

au! BufReadPre
au! FileChangedShell
delfunc Xautocmd_changelist
bwipe! Xerr
call delete('Xerr')
endfunc

" vim: shiftwidth=2 sts=2 expandtab
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -695,6 +695,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
789,
/**/
788,
/**/
Expand Down

0 comments on commit 8f3c3c6

Please sign in to comment.