Mercurial > vim
comparison src/normal.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 | 6d50182e7e24 |
children | 5fbac68bda23 |
comparison
equal
deleted
inserted
replaced
23020:61decb85346b | 23021:d10a37eb91ee |
---|---|
1323 msg(_("Warning: terminal cannot highlight")); | 1323 msg(_("Warning: terminal cannot highlight")); |
1324 did_check = TRUE; | 1324 did_check = TRUE; |
1325 } | 1325 } |
1326 } | 1326 } |
1327 | 1327 |
1328 #if defined(FEAT_CLIPBOARD) && defined(FEAT_EVAL) | |
1329 /* | |
1330 * Call yank_do_autocmd() for "regname". | |
1331 */ | |
1332 static void | |
1333 call_yank_do_autocmd(int regname) | |
1334 { | |
1335 oparg_T oa; | |
1336 yankreg_T *reg; | |
1337 | |
1338 clear_oparg(&oa); | |
1339 oa.regname = regname; | |
1340 oa.op_type = OP_YANK; | |
1341 oa.is_VIsual = TRUE; | |
1342 reg = get_register(regname, TRUE); | |
1343 yank_do_autocmd(&oa, reg); | |
1344 free_register(reg); | |
1345 } | |
1346 #endif | |
1347 | |
1328 /* | 1348 /* |
1329 * End Visual mode. | 1349 * End Visual mode. |
1330 * This function should ALWAYS be called to end Visual mode, except from | 1350 * This function should ALWAYS be called to end Visual mode, except from |
1331 * do_pending_operator(). | 1351 * do_pending_operator(). |
1332 */ | 1352 */ |
1340 * Only do this when the clipboard is already owned. Don't want to grab | 1360 * Only do this when the clipboard is already owned. Don't want to grab |
1341 * the selection when hitting ESC. | 1361 * the selection when hitting ESC. |
1342 */ | 1362 */ |
1343 if (clip_star.available && clip_star.owned) | 1363 if (clip_star.available && clip_star.owned) |
1344 clip_auto_select(); | 1364 clip_auto_select(); |
1365 | |
1366 # if defined(FEAT_EVAL) | |
1367 // Emit a TextYankPost for the automatic copy of the selection into the | |
1368 // star and/or plus register. | |
1369 if (has_textyankpost()) | |
1370 { | |
1371 if (clip_isautosel_star()) | |
1372 call_yank_do_autocmd('*'); | |
1373 if (clip_isautosel_plus()) | |
1374 call_yank_do_autocmd('+'); | |
1375 } | |
1376 # endif | |
1345 #endif | 1377 #endif |
1346 | 1378 |
1347 VIsual_active = FALSE; | 1379 VIsual_active = FALSE; |
1348 setmouse(); | 1380 setmouse(); |
1349 mouse_dragging = 0; | 1381 mouse_dragging = 0; |