changeset 20824:b8ca32dcfabb v8.2.0964

patch 8.2.0964: TextYankPost does not provide info about Visual selection Commit: https://github.com/vim/vim/commit/37d1673ce007c46ec2338f3236ae1b7b0324bd25 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jun 12 22:09:01 2020 +0200 patch 8.2.0964: TextYankPost does not provide info about Visual selection Problem: TextYankPost does not provide info about Visual selection. Solution: Add the 'visual' key in v:event. (closes https://github.com/vim/vim/issues/6249)
author Bram Moolenaar <Bram@vim.org>
date Fri, 12 Jun 2020 22:15:04 +0200
parents 9c648a5f2eda
children deaf5e8bcb72
files runtime/doc/autocmd.txt src/register.c src/testdir/test_autocmd.vim src/version.c
diffstat 4 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/autocmd.txt
+++ b/runtime/doc/autocmd.txt
@@ -1154,6 +1154,8 @@ TextYankPost			After text has been yanke
 						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,
--- a/src/register.c
+++ b/src/register.c
@@ -928,6 +928,8 @@ yank_do_autocmd(oparg_T *oap, yankreg_T 
     }
     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);
 
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -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)
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    964,
+/**/
     963,
 /**/
     962,