]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.0964: TextYankPost does not provide info about Visual selection v8.2.0964
authorBram Moolenaar <Bram@vim.org>
Fri, 12 Jun 2020 20:09:01 +0000 (22:09 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 12 Jun 2020 20:09:01 +0000 (22:09 +0200)
Problem:    TextYankPost does not provide info about Visual selection.
Solution:   Add the 'visual' key in v:event. (closes #6249)

runtime/doc/autocmd.txt
src/register.c
src/testdir/test_autocmd.vim
src/version.c

index 613dd8561c0db7d1436bddb610591906b7211166..5713119cd9bc0dff68bf81d5f51ecb2710db5998 100644 (file)
@@ -1154,6 +1154,8 @@ TextYankPost                      After text has been yanked or deleted in the
                                                register.
                                   regtype      Type of the register, see
                                                |getregtype()|.
+                                  visual       True if the operation is
+                                               performed on a |Visual| area.
                                Not triggered when |quote_| is used nor when
                                called recursively.
                                It is not allowed to change the buffer text,
index f89a530b448c31a18533f3838ff708462cd9de2b..3968b07fb4b6859f9515f6c897b272ced37a6a03 100644 (file)
@@ -928,6 +928,8 @@ yank_do_autocmd(oparg_T *oap, yankreg_T *reg)
     }
     dict_add_string(v_event, "regtype", buf);
 
+    dict_add_bool(v_event, "visual", oap->is_VIsual);
+
     // Lock the dictionary and its keys
     dict_set_items_ro(v_event);
 
index 9ac70700577c1d47331113272fcf497cc9a17e78..cd3559e1bc9e91b1a1d5c5244040ae1da8005581 100644 (file)
@@ -1712,23 +1712,27 @@ func Test_TextYankPost()
 
   norm "ayiw
   call assert_equal(
-    \{'regcontents': ['foo'], 'regname': 'a', 'operator': 'y', 'regtype': 'v'},
+    \{'regcontents': ['foo'], 'regname': 'a', 'operator': 'y', 'regtype': 'v', 'visual': v:false},
     \g:event)
   norm y_
   call assert_equal(
-    \{'regcontents': ['foo'], 'regname': '',  'operator': 'y', 'regtype': 'V'},
+    \{'regcontents': ['foo'], 'regname': '',  'operator': 'y', 'regtype': 'V', 'visual': v:false},
+    \g:event)
+  norm Vy
+  call assert_equal(
+    \{'regcontents': ['foo'], 'regname': '',  'operator': 'y', 'regtype': 'V', 'visual': v:true},
     \g:event)
   call feedkeys("\<C-V>y", 'x')
   call assert_equal(
-    \{'regcontents': ['f'], 'regname': '',  'operator': 'y', 'regtype': "\x161"},
+    \{'regcontents': ['f'], 'regname': '',  'operator': 'y', 'regtype': "\x161", 'visual': v:true},
     \g:event)
   norm "xciwbar
   call assert_equal(
-    \{'regcontents': ['foo'], 'regname': 'x', 'operator': 'c', 'regtype': 'v'},
+    \{'regcontents': ['foo'], 'regname': 'x', 'operator': 'c', 'regtype': 'v', 'visual': v:false},
     \g:event)
   norm "bdiw
   call assert_equal(
-    \{'regcontents': ['bar'], 'regname': 'b', 'operator': 'd', 'regtype': 'v'},
+    \{'regcontents': ['bar'], 'regname': 'b', 'operator': 'd', 'regtype': 'v', 'visual': v:false},
     \g:event)
 
   call assert_equal({}, v:event)
index 1a2b7050b31c165550035124597300102b106e0d..25a096274fcef668af678be363efb71e539b8b64 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    964,
 /**/
     963,
 /**/