diff src/clipboard.c @ 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 ec89debe5037
children 826a6406ea7b
line wrap: on
line diff
--- a/src/clipboard.c
+++ b/src/clipboard.c
@@ -2025,6 +2025,9 @@ clip_get_selection(Clipboard_T *cbd)
 		    && get_y_register(STAR_REGISTER)->y_array != NULL))
 	    return;
 
+	// Avoid triggering autocmds such as TextYankPost.
+	block_autocmds();
+
 	// Get the text between clip_star.start & clip_star.end
 	old_y_previous = get_y_previous();
 	old_y_current = get_y_current();
@@ -2054,6 +2057,8 @@ clip_get_selection(Clipboard_T *cbd)
 	curbuf->b_op_end = old_op_end;
 	VIsual = old_visual;
 	VIsual_mode = old_visual_mode;
+
+	unblock_autocmds();
     }
     else if (!is_clipboard_needs_update())
     {