diff src/testdir/test_autocmd.vim @ 23021:d10a37eb91ee v8.2.2057

patch 8.2.2057: getting the selection may trigger TextYankPost autocmd Commit: https://github.com/vim/vim/commit/fccbf068f8c85474db8d8dead1530321d1f3e5b8 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Nov 26 20:34:00 2020 +0100 patch 8.2.2057: getting the selection may trigger TextYankPost autocmd Problem: Getting the selection may trigger TextYankPost autocmd. Solution: Only trigger the autocommand when yanking in Vim, not for getting the selection. (closes #7367)
author Bram Moolenaar <Bram@vim.org>
date Thu, 26 Nov 2020 20:45:03 +0100
parents ffb173dbf228
children f74978697fb6
line wrap: on
line diff
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -1760,6 +1760,28 @@ func Test_TextYankPost()
 
   call assert_equal({}, v:event)
 
+  if has('clipboard_working') && !has('gui_running')
+    " Test that when the visual selection is automatically copied to clipboard
+    " register a TextYankPost is emitted
+    call setline(1, ['foobar'])
+
+    let @* = ''
+    set clipboard=autoselect
+    exe "norm! ggviw\<Esc>"
+    call assert_equal(
+        \{'regcontents': ['foobar'], 'regname': '*', 'operator': 'y', 'regtype': 'v', 'visual': v:true},
+        \g:event)
+
+    let @+ = ''
+    set clipboard=autoselectplus
+    exe "norm! ggviw\<Esc>"
+    call assert_equal(
+        \{'regcontents': ['foobar'], 'regname': '+', 'operator': 'y', 'regtype': 'v', 'visual': v:true},
+        \g:event)
+
+    set clipboard&vim
+  endif
+
   au! TextYankPost
   unlet g:event
   bwipe!