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)
diff --git a/src/clipboard.c b/src/clipboard.c
index 5db13a0..3084ce1 100644
--- a/src/clipboard.c
+++ b/src/clipboard.c
@@ -2025,6 +2025,9 @@
&& 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 @@
curbuf->b_op_end = old_op_end;
VIsual = old_visual;
VIsual_mode = old_visual_mode;
+
+ unblock_autocmds();
}
else if (!is_clipboard_needs_update())
{