]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name v9.0.0713
authorzeertzjq <zeertzjq@outlook.com>
Mon, 10 Oct 2022 12:46:15 +0000 (13:46 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 10 Oct 2022 12:46:15 +0000 (13:46 +0100)
Problem:    <amatch> of MenuPopup event is expanded like a file name.
Solution:   Do not expand <amatch> for MenuPopup. (closes #11328)

src/autocmd.c
src/testdir/test_menu.vim
src/version.c

index 599db46c7625ba935cf68d378d55969ebb77d97d..93da0bbbb199aa97a765495f0dc53a5eab963aa9 100644 (file)
@@ -2095,6 +2095,7 @@ apply_autocmds_group(
                || event == EVENT_DIRCHANGED
                || event == EVENT_DIRCHANGEDPRE
                || event == EVENT_MODECHANGED
+               || event == EVENT_MENUPOPUP
                || event == EVENT_USER
                || event == EVENT_WINCLOSED
                || event == EVENT_WINSCROLLED)
index 1602e93de6fc90309ae3527d5ac2ea903b5d5786..95d2b01a5c99abc55b0690eb6a5632d3feb17d97 100644 (file)
@@ -479,6 +479,35 @@ func Test_popup_menu()
   unmenu PopUp
 endfunc
 
+" Test for MenuPopup autocommand
+func Test_autocmd_MenuPopup()
+  CheckNotGui
+
+  set mouse=a
+  set mousemodel=popup
+  aunmenu *
+  autocmd MenuPopup * exe printf(
+    \ 'anoremenu PopUp.Foo <Cmd>let g:res = ["%s", "%s"]<CR>',
+    \ expand('<afile>'), expand('<amatch>'))
+
+  call feedkeys("\<RightMouse>\<Down>\<CR>", 'tnix')
+  call assert_equal(['n', 'n'], g:res)
+
+  call feedkeys("v\<RightMouse>\<Down>\<CR>\<Esc>", 'tnix')
+  call assert_equal(['v', 'v'], g:res)
+
+  call feedkeys("gh\<RightMouse>\<Down>\<CR>\<Esc>", 'tnix')
+  call assert_equal(['s', 's'], g:res)
+
+  call feedkeys("i\<RightMouse>\<Down>\<CR>\<Esc>", 'tnix')
+  call assert_equal(['i', 'i'], g:res)
+
+  autocmd! MenuPopup
+  aunmenu PopUp.Foo
+  unlet g:res
+  set mouse& mousemodel&
+endfunc
+
 " Test for listing the menus using the :menu command
 func Test_show_menus()
   " In the GUI, tear-off menu items are present in the output below
index eef7ff101bd4c16683d6facda4ff2717adde1a57..2b57f7d1aa8bc41db2838f38983438ebe079c9e8 100644 (file)
@@ -699,6 +699,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    713,
 /**/
     712,
 /**/