To: vim_dev@googlegroups.com Subject: Patch 8.2.4954 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4954 Problem: Inserting line breaks text property spanning more then one line. Solution: Check TP_FLAG_CONT_PREV and TP_FLAG_CONT_NEXT. (closes #10423) Files: src/textprop.c, src/testdir/test_textprop.vim *** ../vim-8.2.4953/src/textprop.c 2022-04-18 21:53:59.090171080 +0100 --- src/textprop.c 2022-05-14 18:05:44.962637201 +0100 *************** *** 1650,1660 **** proptype_T *pt = text_prop_type_by_id(curbuf, prop->tp_type); int start_incl = (pt != NULL && (pt->pt_flags & PT_FLAG_INS_START_INCL)) ! || (flags & APC_SUBSTITUTE); int end_incl = (pt != NULL ! && (pt->pt_flags & PT_FLAG_INS_END_INCL)); ! // Do not drop zero-width props if they later can increase in ! // size. int droppable = !(start_incl || end_incl); adjustres_T res = {TRUE, FALSE}; --- 1650,1661 ---- proptype_T *pt = text_prop_type_by_id(curbuf, prop->tp_type); int start_incl = (pt != NULL && (pt->pt_flags & PT_FLAG_INS_START_INCL)) ! || (flags & APC_SUBSTITUTE) ! || (prop->tp_flags & TP_FLAG_CONT_PREV); int end_incl = (pt != NULL ! && (pt->pt_flags & PT_FLAG_INS_END_INCL)) ! || (prop->tp_flags & TP_FLAG_CONT_NEXT); ! // Do not drop zero-width props if they later can increase in size. int droppable = !(start_incl || end_incl); adjustres_T res = {TRUE, FALSE}; *** ../vim-8.2.4953/src/testdir/test_textprop.vim 2022-05-13 21:56:24.589080012 +0100 --- src/testdir/test_textprop.vim 2022-05-14 18:08:41.462516709 +0100 *************** *** 1958,1961 **** --- 1958,1994 ---- bwipe! endfunc + func Test_prop_insert_multiline() + new + call AddPropTypes() + + call setline(1, ['foobar', 'barbaz']) + call prop_add(1, 4, #{end_lnum: 2, end_col: 4, type: 'one'}) + + call feedkeys("1Goquxqux\", 'nxt') + call feedkeys("2GOquxqux\", 'nxt') + + let lines =<< trim END + foobar + quxqux + quxqux + barbaz + END + call assert_equal(lines, getline(1, '$')) + let expected = [ + \ {'lnum': 1, 'id': 0, 'col': 4, 'type_bufnr': 0, 'end': 0, 'type': 'one', + \ 'length': 4 ,'start': 1}, + \ {'lnum': 2, 'id': 0, 'col': 1, 'type_bufnr': 0, 'end': 0, 'type': 'one', + \ 'length': 7, 'start': 0}, + \ {'lnum': 3, 'id': 0, 'col': 1, 'type_bufnr': 0, 'end': 0, 'type': 'one', + \ 'length': 7, 'start': 0}, + \ {'lnum': 4, 'id': 0, 'col': 1, 'type_bufnr': 0, 'end': 1, 'type': 'one', + \ 'length': 3, 'start': 0} + \ ] + call assert_equal(expected, prop_list(1, #{end_lnum: 10})) + + call DeletePropTypes() + bwipe! + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.4953/src/version.c 2022-05-14 12:54:18.643640552 +0100 --- src/version.c 2022-05-14 17:57:37.930969641 +0100 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 4954, /**/ -- Some of the well known MS-Windows errors: EMULTI Multitasking attempted, system confused EKEYBOARD Keyboard locked, try getting out of this one! EXPLAIN Unexplained error, please tell us what happened EFUTURE Reserved for our future mistakes /// 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 ///