comparison src/testdir/test_popup.vim @ 23328:8e0ec52cad85 v8.2.2207

patch 8.2.2207: illegal memory access if popup menu items are changed Commit: https://github.com/vim/vim/commit/38455a921395a56690790c8c1d28c1c43ca04c8a Author: Bram Moolenaar <Bram@vim.org> Date: Thu Dec 24 18:39:02 2020 +0100 patch 8.2.2207: illegal memory access if popup menu items are changed Problem: Illegal memory access if popup menu items are changed while the menu is visible. (Tom?? Janou?ek) Solution: Make a copy of the text. (closes #7537)
author Bram Moolenaar <Bram@vim.org>
date Thu, 24 Dec 2020 18:45:03 +0100
parents f7f2d73ff85e
children 385d33dfb7df
comparison
equal deleted inserted replaced
23327:2b493a1b5478 23328:8e0ec52cad85
857 call assert_fails('popup Test.Foo', 'E336:') 857 call assert_fails('popup Test.Foo', 'E336:')
858 call assert_fails('popup Test.Foo.X', 'E327:') 858 call assert_fails('popup Test.Foo.X', 'E327:')
859 call assert_fails('popup Foo', 'E337:') 859 call assert_fails('popup Foo', 'E337:')
860 unmenu Test.Foo 860 unmenu Test.Foo
861 861
862 let script =<< trim END
863 func StartTimer()
864 call timer_start(100, {-> ChangeMenu()})
865 endfunc
866 func ChangeMenu()
867 nunmenu PopUp.&Paste
868 nnoremenu 1.40 PopUp.&Paste :echomsg "pasted"<CR>
869 echomsg 'changed'
870 endfunc
871 END
872 call writefile(script, 'XtimerScript')
873
862 let lines =<< trim END 874 let lines =<< trim END
863 one two three four five 875 one two three four five
864 and one two Xthree four five 876 and one two Xthree four five
865 one more two three four five 877 one more two three four five
866 END 878 END
867 call writefile(lines, 'Xtest') 879 call writefile(lines, 'Xtest')
868 let buf = RunVimInTerminal('Xtest', {}) 880 let buf = RunVimInTerminal('-S XtimerScript Xtest', {})
869 call term_sendkeys(buf, ":source $VIMRUNTIME/menu.vim\<CR>") 881 call term_sendkeys(buf, ":source $VIMRUNTIME/menu.vim\<CR>")
870 call term_sendkeys(buf, "/X\<CR>:popup PopUp\<CR>") 882 call term_sendkeys(buf, "/X\<CR>:popup PopUp\<CR>")
871 call VerifyScreenDump(buf, 'Test_popup_command_01', {}) 883 call VerifyScreenDump(buf, 'Test_popup_command_01', {})
872 884
873 " Select a word 885 " go to the Paste entry in the menu
874 call term_sendkeys(buf, "jj") 886 call term_sendkeys(buf, "jj")
875 call VerifyScreenDump(buf, 'Test_popup_command_02', {}) 887 call VerifyScreenDump(buf, 'Test_popup_command_02', {})
876 888
877 " Select a word 889 " Select a word
878 call term_sendkeys(buf, "j\<CR>") 890 call term_sendkeys(buf, "j\<CR>")
879 call VerifyScreenDump(buf, 'Test_popup_command_03', {}) 891 call VerifyScreenDump(buf, 'Test_popup_command_03', {})
880 892
881 call term_sendkeys(buf, "\<Esc>") 893 call term_sendkeys(buf, "\<Esc>")
894
895 " Set a timer to change a menu entry while it's displayed. The text should
896 " not change but the command does. Making the screendump also verifies that
897 " "changed" shows up, which means the timer triggered
898 call term_sendkeys(buf, "/X\<CR>:call StartTimer() | popup PopUp\<CR>")
899 call VerifyScreenDump(buf, 'Test_popup_command_04', {})
900
901 " Select the Paste entry, executes the changed menu item.
902 call term_sendkeys(buf, "jj\<CR>")
903 call VerifyScreenDump(buf, 'Test_popup_command_05', {})
904
882 call StopVimInTerminal(buf) 905 call StopVimInTerminal(buf)
883 call delete('Xtest') 906 call delete('Xtest')
907 call delete('XtimerScript')
884 endfunc 908 endfunc
885 909
886 func Test_popup_complete_backwards() 910 func Test_popup_complete_backwards()
887 new 911 new
888 call setline(1, ['Post', 'Port', 'Po']) 912 call setline(1, ['Post', 'Port', 'Po'])