Skip to content

Commit 4ff70cc

Browse files
committed
vim-patch:8.1.2416: loading menus sets v:errmsg
Problem: Loading menus sets v:errmsg. Solution: Avoid setting v:errmsg and add a test for that. (Jason Franklin) vim/vim@e24c5b3
1 parent 750f2b6 commit 4ff70cc

File tree

3 files changed

+29
-17
lines changed

3 files changed

+29
-17
lines changed

runtime/delmenu.vim

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,30 @@
22
" Warning: This also deletes all menus defined by the user!
33
"
44
" Maintainer: Bram Moolenaar <[email protected]>
5-
" Last Change: 2001 May 27
5+
" Last Change: 2019 Dec 10
66

77
aunmenu *
88

9-
silent! unlet did_install_default_menus
10-
silent! unlet did_install_syntax_menu
11-
if exists("did_menu_trans")
9+
unlet! g:did_install_default_menus
10+
unlet! g:did_install_syntax_menu
11+
12+
if exists('g:did_menu_trans')
1213
menutrans clear
13-
unlet did_menu_trans
14+
unlet g:did_menu_trans
1415
endif
1516

16-
silent! unlet find_help_dialog
17+
unlet! g:find_help_dialog
1718

18-
silent! unlet menutrans_help_dialog
19-
silent! unlet menutrans_path_dialog
20-
silent! unlet menutrans_tags_dialog
21-
silent! unlet menutrans_textwidth_dialog
22-
silent! unlet menutrans_fileformat_dialog
23-
silent! unlet menutrans_no_file
19+
unlet! g:menutrans_fileformat_choices
20+
unlet! g:menutrans_fileformat_dialog
21+
unlet! g:menutrans_help_dialog
22+
unlet! g:menutrans_no_file
23+
unlet! g:menutrans_path_dialog
24+
unlet! g:menutrans_set_lang_to
25+
unlet! g:menutrans_spell_add_ARG_to_word_list
26+
unlet! g:menutrans_spell_change_ARG_to
27+
unlet! g:menutrans_spell_ignore_ARG
28+
unlet! g:menutrans_tags_dialog
29+
unlet! g:menutrans_textwidth_dialog
2430

2531
" vim: set sw=2 :

runtime/menu.vim

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
" You can also use this as a start for your own set of menus.
33
"
44
" Maintainer: Bram Moolenaar <[email protected]>
5-
" Last Change: 2019 Jan 27
5+
" Last Change: 2019 Dec 10
66

77
" Note that ":an" (short for ":anoremenu") is often used to make a menu work
88
" in all modes and avoid side effects from mappings defined by the user.
@@ -690,11 +690,11 @@ func! s:BMShow(...)
690690
let g:bmenu_priority = a:1
691691
endif
692692

693-
" remove old menu, if exists; keep one entry to avoid a torn off menu to
694-
" disappear.
695-
silent! unmenu &Buffers
693+
" Remove old menu, if exists; keep one entry to avoid a torn off menu to
694+
" disappear. Use try/catch to avoid setting v:errmsg
695+
try | unmenu &Buffers | catch | endtry
696696
exe 'noremenu ' . g:bmenu_priority . ".1 &Buffers.Dummy l"
697-
silent! unmenu! &Buffers
697+
try | unmenu! &Buffers | catch | endtry
698698

699699
" create new menu; set 'cpo' to include the <CR>
700700
let cpo_save = &cpo

src/nvim/testdir/test_menu.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ func Test_load_menu()
1111
call assert_report('error while loading menus: ' . v:exception)
1212
endtry
1313
call assert_match('browse confirm w', execute(':menu File.Save'))
14+
15+
let v:errmsg = ''
16+
doautocmd LoadBufferMenu VimEnter
17+
call assert_equal('', v:errmsg)
18+
1419
source $VIMRUNTIME/delmenu.vim
20+
call assert_equal('', v:errmsg)
1521
endfunc
1622

1723
func Test_translate_menu()

0 commit comments

Comments
 (0)