mirror of
https://github.com/neovim/neovim.git
synced 2025-10-14 22:06:07 +00:00
vim-patch:8.2.0413: buffer menu does not handle special buffers properly
Problem: Buffer menu does not handle special buffers properly.
Solution: Keep a dictionary with buffer names to reliably keep track of
entries.
Also trigger BufFilePre and BufFilePost for command-line and
terminal buffers when the name changes.
5e94a29ebb
This commit is contained in:
@@ -5639,7 +5639,9 @@ void wipe_buffer(buf_T *buf, bool aucmd)
|
||||
void buf_open_scratch(handle_T bufnr, char *bufname)
|
||||
{
|
||||
(void)do_ecmd((int)bufnr, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, NULL);
|
||||
apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, false, curbuf);
|
||||
(void)setfname(curbuf, bufname, NULL, true);
|
||||
apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, false, curbuf);
|
||||
set_option_value("bh", 0L, "hide", OPT_LOCAL);
|
||||
set_option_value("bt", 0L, "nofile", OPT_LOCAL);
|
||||
set_option_value("swf", 0L, NULL, OPT_LOCAL);
|
||||
|
@@ -9914,7 +9914,11 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
// at this point the buffer has no terminal instance associated yet, so unset
|
||||
// the 'swapfile' option to ensure no swap file will be created
|
||||
curbuf->b_p_swf = false;
|
||||
|
||||
apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, false, curbuf);
|
||||
(void)setfname(curbuf, (char *)NameBuff, NULL, true);
|
||||
apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, false, curbuf);
|
||||
|
||||
// Save the job id and pid in b:terminal_job_{id,pid}
|
||||
Error err = ERROR_INIT;
|
||||
// deprecated: use 'channel' buffer option
|
||||
|
@@ -16,7 +16,6 @@ source test_ga.vim
|
||||
source test_glob2regpat.vim
|
||||
source test_global.vim
|
||||
source test_lispwords.vim
|
||||
source test_menu.vim
|
||||
source test_move.vim
|
||||
source test_put.vim
|
||||
source test_reltime.vim
|
||||
|
@@ -19,6 +19,41 @@ func Test_load_menu()
|
||||
call assert_equal('', v:errmsg)
|
||||
endfunc
|
||||
|
||||
func Test_buffer_menu_special_buffers()
|
||||
" Load in runtime menus
|
||||
try
|
||||
source $VIMRUNTIME/menu.vim
|
||||
catch
|
||||
call assert_report('error while loading menus: ' . v:exception)
|
||||
endtry
|
||||
|
||||
let v:errmsg = ''
|
||||
doautocmd LoadBufferMenu VimEnter
|
||||
call assert_equal('', v:errmsg)
|
||||
|
||||
let orig_buffer_menus = execute("nmenu Buffers")
|
||||
|
||||
" Make a new command-line window, test that it does not create a new buffer
|
||||
" menu.
|
||||
call feedkeys("q::let cmdline_buffer_menus=execute('nmenu Buffers')\<CR>:q\<CR>", 'ntx')
|
||||
call assert_equal(len(split(orig_buffer_menus, "\n")), len(split(cmdline_buffer_menus, "\n")))
|
||||
call assert_equal(orig_buffer_menus, execute("nmenu Buffers"))
|
||||
|
||||
if has('terminal')
|
||||
" Open a terminal window and test that it does not create a buffer menu
|
||||
" item.
|
||||
terminal
|
||||
let term_buffer_menus = execute('nmenu Buffers')
|
||||
call assert_equal(len(split(orig_buffer_menus, "\n")), len(split(term_buffer_menus, "\n")))
|
||||
bwipe!
|
||||
call assert_equal(orig_buffer_menus, execute("nmenu Buffers"))
|
||||
endif
|
||||
|
||||
" Remove menus to clean up
|
||||
source $VIMRUNTIME/delmenu.vim
|
||||
call assert_equal('', v:errmsg)
|
||||
endfunc
|
||||
|
||||
func Test_translate_menu()
|
||||
if !has('multi_lang')
|
||||
return
|
||||
@@ -121,6 +156,7 @@ endfunc
|
||||
" Test for menu item completion in command line
|
||||
func Test_menu_expand()
|
||||
" Create the menu itmes for test
|
||||
menu Dummy.Nothing lll
|
||||
for i in range(1, 4)
|
||||
let m = 'menu Xmenu.A' .. i .. '.A' .. i
|
||||
for j in range(1, 4)
|
||||
@@ -146,7 +182,7 @@ func Test_menu_expand()
|
||||
" Test for <Up> to go up a menu
|
||||
call feedkeys(":emenu Xmenu.A\<Tab>\<Down>\<Up>\<Up>\<Up>" ..
|
||||
\ "\<C-A>\<C-B>\"\<CR>", 'xt')
|
||||
call assert_equal('"emenu Buffers. Xmenu.', @:)
|
||||
call assert_equal('"emenu Dummy. Xmenu.', @:)
|
||||
|
||||
" Test for expanding only submenus
|
||||
call feedkeys(":popup Xmenu.\<C-A>\<C-B>\"\<CR>", 'xt')
|
||||
@@ -166,6 +202,7 @@ func Test_menu_expand()
|
||||
|
||||
set wildmenu&
|
||||
unmenu Xmenu
|
||||
unmenu Dummy
|
||||
|
||||
" Test for expanding popup menus with some hidden items
|
||||
menu Xmenu.foo.A1 a1
|
||||
@@ -175,7 +212,6 @@ func Test_menu_expand()
|
||||
call feedkeys(":popup Xmenu.\<C-A>\<C-B>\"\<CR>", 'xt')
|
||||
call assert_equal('"popup Xmenu.foo', @:)
|
||||
unmenu Xmenu
|
||||
|
||||
endfunc
|
||||
|
||||
" Test for the menu_info() function
|
||||
|
Reference in New Issue
Block a user