changeset 30757:74043ee52030 v9.0.0713

patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name Commit: https://github.com/vim/vim/commit/c601d988b6b1a672f71e3d61f4aaa4f7742a3a21 Author: zeertzjq <zeertzjq@outlook.com> Date: Mon Oct 10 13:46:15 2022 +0100 patch 9.0.0713: <amatch> of MenuPopup event is expanded like a file name Problem: <amatch> of MenuPopup event is expanded like a file name. Solution: Do not expand <amatch> for MenuPopup. (closes https://github.com/vim/vim/issues/11328)
author Bram Moolenaar <Bram@vim.org>
date Mon, 10 Oct 2022 15:00:09 +0200
parents 05d7469d2529
children 483fb487e57c
files src/autocmd.c src/testdir/test_menu.vim src/version.c
diffstat 3 files changed, 32 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/autocmd.c
+++ b/src/autocmd.c
@@ -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)
--- a/src/testdir/test_menu.vim
+++ b/src/testdir/test_menu.vim
@@ -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
--- a/src/version.c
+++ b/src/version.c
@@ -700,6 +700,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    713,
+/**/
     712,
 /**/
     711,