]> granicus.if.org Git - vim/commitdiff
patch 8.2.0478: new buffers are not added to the Buffers menu v8.2.0478
authorBram Moolenaar <Bram@vim.org>
Sun, 29 Mar 2020 18:08:45 +0000 (20:08 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 29 Mar 2020 18:08:45 +0000 (20:08 +0200)
Problem:    New buffers are not added to the Buffers menu.
Solution:   Turn number into string. (Yee Cheng Chin, closes #5864)

runtime/menu.vim
src/testdir/test_menu.vim
src/version.c

index b17e8ea884e9d2dea08215c1282b8a73e46456fa..8400180aaa1f5315dd2b9363046f6c3d2c8876b4 100644 (file)
@@ -2,7 +2,7 @@
 " You can also use this as a start for your own set of menus.
 "
 " Maintainer:  Bram Moolenaar <Bram@vim.org>
-" Last Change: 2020 Mar 19
+" Last Change: 2020 Mar 29
 
 " Note that ":an" (short for ":anoremenu") is often used to make a menu work
 " in all modes and avoid side effects from mappings defined by the user.
@@ -672,7 +672,7 @@ func s:BMAdd()
       call s:BMShow()
     else
       let name = expand("<afile>")
-      let num = expand("<abuf>")
+      let num = expand("<abuf>") + 0 " add zero to convert to a number type
       if s:BMCanAdd(name, num)
        call <SID>BMFilename(name, num)
        let s:bmenu_count += 1
index f8d808119076833716aa8ab7ac498a5ba957f6ec..85d54f0833b72a89b19f08141efdb76d7f330b21 100644 (file)
@@ -33,10 +33,17 @@ func Test_buffer_menu_special_buffers()
 
   let orig_buffer_menus = execute("nmenu Buffers")
 
+  " Test that regular new buffer results in a new buffer menu item.
+  new
+  let new_buffer_menus = execute('nmenu Buffers')
+  call assert_equal(len(split(orig_buffer_menus, "\n")) + 2, len(split(new_buffer_menus, "\n")))
+  bwipe!
+  call assert_equal(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(len(split(orig_buffer_menus, "\n")) + 2, len(split(cmdline_buffer_menus, "\n")))
   call assert_equal(orig_buffer_menus, execute("nmenu Buffers"))
 
   if has('terminal')
@@ -44,7 +51,7 @@ func Test_buffer_menu_special_buffers()
     " item.
     terminal
     let term_buffer_menus = execute('nmenu Buffers')
-    call assert_equal(len(split(orig_buffer_menus, "\n")), len(split(term_buffer_menus, "\n")))
+    call assert_equal(len(split(orig_buffer_menus, "\n")) + 2, len(split(term_buffer_menus, "\n")))
     bwipe!
     call assert_equal(orig_buffer_menus, execute("nmenu Buffers"))
   endif
@@ -155,6 +162,9 @@ endfunc
 
 " Test for menu item completion in command line
 func Test_menu_expand()
+  " Make sure we don't have stale menu items like Buffers menu.
+  source $VIMRUNTIME/delmenu.vim
+
   " Create the menu itmes for test
   menu Dummy.Nothing lll
   for i in range(1, 4)
index 13a1c30fe22f87cc32a154373f3a5b3b92a5c174..402ed4053885f74e87f97b8d4b645ebdc8f9f890 100644 (file)
@@ -738,6 +738,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    478,
 /**/
     477,
 /**/