To: vim_dev@googlegroups.com Subject: Patch 8.2.4717 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4717 Problem: For TextYankPost v:event does not contain information about the operation being inclusive or not. Solution: Add "inclusive" to v:event. (Justn M. Keyes, Yegappan Lakshmanan, closes #10125) Files: runtime/doc/autocmd.txt, src/register.c, src/testdir/test_autocmd.vim *** ../vim-8.2.4716/runtime/doc/autocmd.txt 2022-04-08 15:17:53.067952553 +0100 --- runtime/doc/autocmd.txt 2022-04-09 11:31:59.776617172 +0100 *************** *** 1203,1216 **** current buffer. The following values of |v:event| can be used to determine the operation that triggered this autocmd: operator The operation performed. regcontents Text that was stored in the register, as a list of lines, like with: > getreg(r, 1, 1) ! < regname Name of the |register| or ! empty string for the unnamed ! register. regtype Type of the register, see |getregtype()|. visual True if the operation is --- 1205,1221 ---- current buffer. The following values of |v:event| can be used to determine the operation that triggered this autocmd: + inclusive TRUE if the motion is + |inclusive| else the motion is + |exclusive|. operator The operation performed. regcontents Text that was stored in the register, as a list of lines, like with: > getreg(r, 1, 1) ! < regname Name of the register or empty ! string for the unnamed ! register, see |registers|. regtype Type of the register, see |getregtype()|. visual True if the operation is *** ../vim-8.2.4716/src/register.c 2022-03-30 10:57:36.735346197 +0100 --- src/register.c 2022-04-09 11:31:59.776617172 +0100 *************** *** 1013,1032 **** --- 1013,1040 ---- list = list_alloc(); if (list == NULL) return; + + // yanked text contents for (n = 0; n < reg->y_size; n++) list_append_string(list, reg->y_array[n], -1); list->lv_lock = VAR_FIXED; (void)dict_add_list(v_event, "regcontents", list); + // register name or empty string for unnamed operation buf[0] = (char_u)oap->regname; buf[1] = NUL; (void)dict_add_string(v_event, "regname", buf); + // motion type: inclusive or exclusive + (void)dict_add_bool(v_event, "inclusive", oap->inclusive); + + // kind of operation (yank, delete, change) buf[0] = get_op_char(oap->op_type); buf[1] = get_extra_op_char(oap->op_type); buf[2] = NUL; (void)dict_add_string(v_event, "operator", buf); + // register type buf[0] = NUL; buf[1] = NUL; switch (get_reg_type(oap->regname, ®len)) *************** *** 1040,1045 **** --- 1048,1054 ---- } (void)dict_add_string(v_event, "regtype", buf); + // selection type - visual or not (void)dict_add_bool(v_event, "visual", oap->is_VIsual); // Lock the dictionary and its keys *** ../vim-8.2.4716/src/testdir/test_autocmd.vim 2022-04-08 15:17:53.075952529 +0100 --- src/testdir/test_autocmd.vim 2022-04-09 11:31:59.776617172 +0100 *************** *** 1931,1958 **** norm "ayiw call assert_equal( ! \{'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', 'visual': v:false}, ! \g:event) norm Vy call assert_equal( ! \{'regcontents': ['foo'], 'regname': '', 'operator': 'y', 'regtype': 'V', 'visual': v:true}, ! \g:event) call feedkeys("\y", 'x') call assert_equal( ! \{'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', 'visual': v:false}, ! \g:event) norm "bdiw call assert_equal( ! \{'regcontents': ['bar'], 'regname': 'b', 'operator': 'd', 'regtype': 'v', 'visual': v:false}, ! \g:event) call assert_equal({}, v:event) --- 1931,1978 ---- norm "ayiw call assert_equal( ! \ #{regcontents: ['foo'], regname: 'a', operator: 'y', ! \ regtype: 'v', visual: v:false, inclusive: v:true}, ! \ g:event) norm y_ call assert_equal( ! \ #{regcontents: ['foo'], regname: '', operator: 'y', regtype: 'V', ! \ visual: v:false, inclusive: v:false}, ! \ g:event) norm Vy call assert_equal( ! \ #{regcontents: ['foo'], regname: '', operator: 'y', regtype: 'V', ! \ visual: v:true, inclusive: v:true}, ! \ g:event) call feedkeys("\y", 'x') call assert_equal( ! \ #{regcontents: ['f'], regname: '', operator: 'y', regtype: "\x161", ! \ visual: v:true, inclusive: v:true}, ! \ g:event) norm "xciwbar call assert_equal( ! \ #{regcontents: ['foo'], regname: 'x', operator: 'c', regtype: 'v', ! \ visual: v:false, inclusive: v:true}, ! \ g:event) norm "bdiw call assert_equal( ! \ #{regcontents: ['bar'], regname: 'b', operator: 'd', regtype: 'v', ! \ visual: v:false, inclusive: v:true}, ! \ g:event) ! ! call setline(1, 'foobar') ! " exclusive motion ! norm $"ay0 ! call assert_equal( ! \ #{regcontents: ['fooba'], regname: 'a', operator: 'y', regtype: 'v', ! \ visual: v:false, inclusive: v:false}, ! \ g:event) ! " inclusive motion ! norm 0"ay$ ! call assert_equal( ! \ #{regcontents: ['foobar'], regname: 'a', operator: 'y', regtype: 'v', ! \ visual: v:false, inclusive: v:true}, ! \ g:event) call assert_equal({}, v:event) *************** *** 1965,1979 **** set clipboard=autoselect exe "norm! ggviw\" call assert_equal( ! \{'regcontents': ['foobar'], 'regname': '*', 'operator': 'y', 'regtype': 'v', 'visual': v:true}, ! \g:event) let @+ = '' set clipboard=autoselectplus exe "norm! ggviw\" call assert_equal( ! \{'regcontents': ['foobar'], 'regname': '+', 'operator': 'y', 'regtype': 'v', 'visual': v:true}, ! \g:event) set clipboard&vim endif --- 1985,2001 ---- set clipboard=autoselect exe "norm! ggviw\" call assert_equal( ! \ #{regcontents: ['foobar'], regname: '*', operator: 'y', ! \ regtype: 'v', visual: v:true, inclusive: v:false}, ! \ g:event) let @+ = '' set clipboard=autoselectplus exe "norm! ggviw\" call assert_equal( ! \ #{regcontents: ['foobar'], regname: '+', operator: 'y', ! \ regtype: 'v', visual: v:true, inclusive: v:false}, ! \ g:event) set clipboard&vim endif *** ../vim-8.2.4716/src/version.c 2022-04-09 11:09:03.530052273 +0100 --- src/version.c 2022-04-09 11:34:54.012437995 +0100 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 4717, /**/ -- We apologise again for the fault in the subtitles. Those responsible for sacking the people who have just been sacked have been sacked. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///