To: vim_dev@googlegroups.com Subject: Patch 8.2.1690 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1690 Problem: Text properties not adjusted for "I" in Visual block mode. Solution: Call inserted_bytes(). Files: src/ops.c, src/change.c, src/proto/change.pro, src/testdir/test_textprop.vim *** ../vim-8.2.1689/src/ops.c 2020-09-15 20:34:04.832428486 +0200 --- src/ops.c 2020-09-15 21:22:26.144272811 +0200 *************** *** 481,486 **** --- 481,487 ---- int count = 0; // extra spaces to replace a cut TAB int spaces = 0; // non-zero if cutting a TAB colnr_T offset; // pointer along new line + colnr_T startcol; // column where insert starts unsigned s_len; // STRLEN(s) char_u *newp, *oldp; // new, old lines linenr_T lnum; // loop var *************** *** 553,561 **** // insert pre-padding vim_memset(newp + offset, ' ', (size_t)spaces); // copy the new text ! mch_memmove(newp + offset + spaces, s, (size_t)s_len); offset += s_len; if (spaces && !bdp->is_short) --- 554,563 ---- // insert pre-padding vim_memset(newp + offset, ' ', (size_t)spaces); + startcol = offset + spaces; // copy the new text ! mch_memmove(newp + startcol, s, (size_t)s_len); offset += s_len; if (spaces && !bdp->is_short) *************** *** 574,579 **** --- 576,585 ---- ml_replace(lnum, newp, FALSE); + if (b_insert) + // correct any text properties + inserted_bytes(lnum, startcol, s_len); + if (lnum == oap->end.lnum) { // Set "']" mark to the end of the block instead of the end of *** ../vim-8.2.1689/src/change.c 2020-05-30 20:30:42.888816585 +0200 --- src/change.c 2020-09-15 21:16:24.961107605 +0200 *************** *** 693,699 **** * Like changed_bytes() but also adjust text properties for "added" bytes. * When "added" is negative text was deleted. */ ! static void inserted_bytes(linenr_T lnum, colnr_T col, int added UNUSED) { #ifdef FEAT_PROP_POPUP --- 693,699 ---- * Like changed_bytes() but also adjust text properties for "added" bytes. * When "added" is negative text was deleted. */ ! void inserted_bytes(linenr_T lnum, colnr_T col, int added UNUSED) { #ifdef FEAT_PROP_POPUP *** ../vim-8.2.1689/src/proto/change.pro 2019-12-12 12:55:15.000000000 +0100 --- src/proto/change.pro 2020-09-15 21:17:36.504954514 +0200 *************** *** 9,14 **** --- 9,15 ---- void invoke_listeners(buf_T *buf); void remove_listeners(buf_T *buf); void changed_bytes(linenr_T lnum, colnr_T col); + void inserted_bytes(linenr_T lnum, colnr_T col, int added); void appended_lines(linenr_T lnum, long count); void appended_lines_mark(linenr_T lnum, long count); void deleted_lines(linenr_T lnum, long count); *** ../vim-8.2.1689/src/testdir/test_textprop.vim 2020-09-15 20:34:04.832428486 +0200 --- src/testdir/test_textprop.vim 2020-09-15 21:33:34.066497138 +0200 *************** *** 1314,1317 **** --- 1314,1348 ---- call prop_type_delete('test') endfunc + func Test_prop_block_insert() + new + call prop_type_add('test', {'highlight': 'ErrorMsg'}) + call setline(1, ['one ', 'two ']) + call prop_add(1, 1, {'length': 3, 'type': 'test'}) + call prop_add(2, 1, {'length': 3, 'type': 'test'}) + + " insert "xx" in the first column of both lines + exe "normal! gg0\jIxx\" + eval getline(1, 2)->assert_equal(['xxone ', 'xxtwo ']) + let expected = [#{id: 0, col: 3, end: 1, type: 'test', length: 3, start: 1}] + eval prop_list(1)->assert_equal(expected) + eval prop_list(2)->assert_equal(expected) + + " insert "yy" inside the text props to make them longer + exe "normal! gg03l\jIyy\" + eval getline(1, 2)->assert_equal(['xxoyyne ', 'xxtyywo ']) + let expected[0].length = 5 + eval prop_list(1)->assert_equal(expected) + eval prop_list(2)->assert_equal(expected) + + " insert "zz" after the text props, text props don't change + exe "normal! gg07l\jIzz\" + eval getline(1, 2)->assert_equal(['xxoyynezz ', 'xxtyywozz ']) + eval prop_list(1)->assert_equal(expected) + eval prop_list(2)->assert_equal(expected) + + bwipe! + call prop_type_delete('test') + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.1689/src/version.c 2020-09-15 20:52:03.164972054 +0200 --- src/version.c 2020-09-15 21:17:28.680971620 +0200 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 1690, /**/ -- "I love deadlines. I especially like the whooshing sound they make as they go flying by." -- Douglas Adams /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///