diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/buffer.c | 2 | ||||
-rw-r--r-- | src/nvim/eval/funcs.c | 4 | ||||
-rw-r--r-- | src/nvim/testdir/test_alot.vim | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test_menu.vim | 40 |
4 files changed, 44 insertions, 3 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 6dd71e92a6..671f0db077 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -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); diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index b3cfec8709..d121c106d0 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -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 diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim index 966b8ef571..a83ef50abc 100644 --- a/src/nvim/testdir/test_alot.vim +++ b/src/nvim/testdir/test_alot.vim @@ -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 diff --git a/src/nvim/testdir/test_menu.vim b/src/nvim/testdir/test_menu.vim index 28db050f82..d3287d4ea9 100644 --- a/src/nvim/testdir/test_menu.vim +++ b/src/nvim/testdir/test_menu.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 |