To: vim_dev@googlegroups.com Subject: Patch 8.1.2308 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.2308 Problem: Deleting text before zero-width textprop removes it. Solution: Keep zero-width textprop when deleting text. Files: src/textprop.c, src/testdir/test_textprop.vim *** ../vim-8.1.2307/src/textprop.c 2019-11-13 16:37:23.239373194 +0100 --- src/textprop.c 2019-11-16 20:32:25.822823787 +0100 *************** *** 1075,1084 **** --- 1075,1087 ---- } else if (bytes_added <= 0 && (tmp_prop.tp_col > col + 1)) { + int len_changed = FALSE; + if (tmp_prop.tp_col + bytes_added < col + 1) { tmp_prop.tp_len += (tmp_prop.tp_col - 1 - col) + bytes_added; tmp_prop.tp_col = col + 1; + len_changed = TRUE; } else tmp_prop.tp_col += bytes_added; *************** *** 1086,1092 **** if ((flags & APC_SAVE_FOR_UNDO) && !dirty) u_savesub(lnum); dirty = TRUE; ! if (tmp_prop.tp_len <= 0) continue; // drop this text property } else if (tmp_prop.tp_len > 0 --- 1089,1095 ---- if ((flags & APC_SAVE_FOR_UNDO) && !dirty) u_savesub(lnum); dirty = TRUE; ! if (len_changed && tmp_prop.tp_len <= 0) continue; // drop this text property } else if (tmp_prop.tp_len > 0 *** ../vim-8.1.2307/src/testdir/test_textprop.vim 2019-11-12 22:44:16.415538386 +0100 --- src/testdir/test_textprop.vim 2019-11-16 20:40:00.221247550 +0100 *************** *** 650,655 **** --- 650,684 ---- call prop_type_delete('comment') endfunc + func Test_prop_delete_text() + new + call prop_type_add('comment', {'highlight': 'Directory'}) + call setline(1, ['oneone', 'twotwo', 'three']) + + " zero length property + call prop_add(1, 3, {'type': 'comment'}) + let expected = [{'col': 3, 'length': 0, 'id': 0, 'type': 'comment', 'start': 1, 'end': 1} ] + call assert_equal(expected, prop_list(1)) + + " delete one char moves the property + normal! x + let expected = [{'col': 2, 'length': 0, 'id': 0, 'type': 'comment', 'start': 1, 'end': 1} ] + call assert_equal(expected, prop_list(1)) + + " delete char of the property has no effect + normal! lx + let expected = [{'col': 2, 'length': 0, 'id': 0, 'type': 'comment', 'start': 1, 'end': 1} ] + call assert_equal(expected, prop_list(1)) + + " delete more chars moves property to first column, is not deleted + normal! 0xxxx + let expected = [{'col': 1, 'length': 0, 'id': 0, 'type': 'comment', 'start': 1, 'end': 1} ] + call assert_equal(expected, prop_list(1)) + + bwipe! + call prop_type_delete('comment') + endfunc + " screenshot test with textprop highlighting func Test_textprop_screenshot_various() CheckScreendump *** ../vim-8.1.2307/src/version.c 2019-11-16 20:03:27.405056583 +0100 --- src/version.c 2019-11-16 20:41:01.257002850 +0100 *************** *** 743,744 **** --- 743,746 ---- { /* Add new patch number below this line */ + /**/ + 2308, /**/ -- Warning label on a superhero Halloween costume: "Caution: Cape does not enable user to fly." /// 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 ///