[BUG] v:errmsg is set when opening gVim

7 views
Skip to first unread message

Jason Franklin

unread,
Dec 10, 2019, 2:25:53 PM12/10/19
to vim_dev
Greetings,

Found a small bug.

Reproduce:

1. gVim --clean
2. :echo v:errmsg

The error message is due to some missing error checking in menu.vim. I updated the test for this script.

I also noticed that delmenu.vim uses :silent! instead of :unlet!.  The latter is preferable because it doesn't leave behind an unnecessary v:errmsg.

Patch follows:

diff --git a/runtime/delmenu.vim b/runtime/delmenu.vim
index 137218264..d4cb5cf30 100644
--- a/runtime/delmenu.vim
+++ b/runtime/delmenu.vim
@@ -7,25 +7,26 @@
 aunmenu *
 tlunmenu *

-silent! unlet did_install_default_menus
-silent! unlet did_install_syntax_menu
-if exists("did_menu_trans")
+unlet! g:did_install_default_menus
+unlet! g:did_install_syntax_menu
+
+if exists('g:did_menu_trans')
   menutrans clear
-  unlet did_menu_trans
+  unlet g:did_menu_trans
 endif

-silent! unlet find_help_dialog
+unlet! g:find_help_dialog

-silent! unlet menutrans_help_dialog
-silent! unlet menutrans_path_dialog
-silent! unlet menutrans_tags_dialog
-silent! unlet menutrans_textwidth_dialog
-silent! unlet menutrans_fileformat_dialog
-silent! unlet menutrans_fileformat_choices
-silent! unlet menutrans_no_file
-silent! unlet menutrans_set_lang_to
-silent! unlet menutrans_spell_change_ARG_to
-silent! unlet menutrans_spell_add_ARG_to_word_list
-silent! unlet menutrans_spell_ignore_ARG
+unlet! g:menutrans_fileformat_choices
+unlet! g:menutrans_fileformat_dialog
+unlet! g:menutrans_help_dialog
+unlet! g:menutrans_no_file
+unlet! g:menutrans_path_dialog
+unlet! g:menutrans_set_lang_to
+unlet! g:menutrans_spell_add_ARG_to_word_list
+unlet! g:menutrans_spell_change_ARG_to
+unlet! g:menutrans_spell_ignore_ARG
+unlet! g:menutrans_tags_dialog
+unlet! g:menutrans_textwidth_dialog

 " vim: set sw=2 :
diff --git a/runtime/menu.vim b/runtime/menu.vim
index 8a98d49a1..4b893e6fc 100644
--- a/runtime/menu.vim
+++ b/runtime/menu.vim
@@ -702,9 +702,9 @@ func! s:BMShow(...)

   " remove old menu, if exists; keep one entry to avoid a torn off menu to
   " disappear.
-  silent! unmenu &Buffers
+  try | unmenu &Buffers | catch | endtry
   exe 'noremenu ' . g:bmenu_priority . ".1 &Buffers.Dummy l"
-  silent! unmenu! &Buffers
+  try | unmenu! &Buffers | catch | endtry

   " create new menu; set 'cpo' to include the <CR>
   let cpo_save = &cpo
diff --git a/src/testdir/test_menu.vim b/src/testdir/test_menu.vim
index efbb982b0..50155fe28 100644
--- a/src/testdir/test_menu.vim
+++ b/src/testdir/test_menu.vim
@@ -10,7 +10,14 @@ func Test_load_menu()
     call assert_report('error while loading menus: ' . v:exception)
   endtry
   call assert_match('browse confirm w', execute(':menu File.Save'))
+
+  let v:errmsg = ''
+
+  doautocmd LoadBufferMenu VimEnter
+  call assert_true(empty(v:errmsg), v:errmsg)
+
   source $VIMRUNTIME/delmenu.vim
+  call assert_true(empty(v:errmsg), v:errmsg)
 endfunc

 func Test_translate_menu()


--
Jason Franklin

Bram Moolenaar

unread,
Dec 10, 2019, 4:12:33 PM12/10/19
to vim...@googlegroups.com, Jason Franklin

Jason Franklin wrote:

> Found a small bug.
>
> Reproduce:
>
> 1. gVim --clean
> 2. :echo v:errmsg
>
> The error message is due to some missing error checking in menu.vim. I
> updated the test for this script.
>
> I also noticed that delmenu.vim uses :silent! instead of :unlet!. The
> latter is preferable because it doesn't leave behind an unnecessary
> v:errmsg.
>
> Patch follows:

Thanks!

--
Eagles may soar, but weasels don't get sucked into jet engines.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages