]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.4728: no test that v:event cannot be modified v8.2.4728
authorzeertzjq <zeertzjq@outlook.com>
Sun, 10 Apr 2022 10:44:04 +0000 (11:44 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 10 Apr 2022 10:44:04 +0000 (11:44 +0100)
Problem:    No test that v:event cannot be modified.
Solution:   Add a test. (closes #10139)

src/testdir/test_autocmd.vim
src/version.c

index 896c563f7d60336b3ec3de3ac81b6fc1bff397e4..9af79d8e1ba31ed2dbbff3b379ce8c0e16f4c54c 100644 (file)
@@ -3117,5 +3117,23 @@ func Test_bufwipeout_changes_window()
   %bwipe!
 endfunc
 
+func Test_v_event_readonly()
+  autocmd CompleteChanged * let v:event.width = 0
+  call assert_fails("normal! i\<C-X>\<C-V>", 'E46:')
+  au! CompleteChanged
+
+  autocmd DirChangedPre * let v:event.directory = ''
+  call assert_fails('cd .', 'E46:')
+  au! DirChangedPre
+
+  autocmd ModeChanged * let v:event.new_mode = ''
+  call assert_fails('normal! cc', 'E46:')
+  au! ModeChanged
+
+  autocmd TextYankPost * let v:event.operator = ''
+  call assert_fails('normal! yy', 'E46:')
+  au! TextYankPost
+endfunc
+
 
 " vim: shiftwidth=2 sts=2 expandtab
index ff5f399de37f1b55a4c6c0a9bf863d5c1a3421af..9657184d206efc5df2f57ed6bc5c934bc6a136b5 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4728,
 /**/
     4727,
 /**/