diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-03-19 18:46:57 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-03-19 18:46:57 +0100 |
commit | 5e94a29ebbde10dd973d58f1adba9a2fc83877d1 (patch) | |
tree | 66b87e6f87e558d31f2313791895a428fe9dead3 /src/testdir/test_menu.vim | |
parent | 37f471df6ee422beb4d08ee4ccda35f8279e3bb7 (diff) |
patch 8.2.0413: buffer menu does not handle special buffers properlyv8.2.0413
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.
Diffstat (limited to 'src/testdir/test_menu.vim')
-rw-r--r-- | src/testdir/test_menu.vim | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/src/testdir/test_menu.vim b/src/testdir/test_menu.vim index 5e7a77b249..f8d8081190 100644 --- a/src/testdir/test_menu.vim +++ b/src/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 |