To: vim_dev@googlegroups.com Subject: Patch 8.2.3062 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3062 Problem: Internal error when adding several text properties. Solution: Do not handle text properties when deleting a line for splitting a data block. (closes #8466) Files: src/structs.h, src/memline.c, src/testdir/test_textprop.vim *** ../vim-8.2.3061/src/structs.h 2021-06-20 19:28:10.273021391 +0200 --- src/structs.h 2021-06-27 12:59:25.891174884 +0200 *************** *** 769,774 **** --- 769,775 ---- // Values for the flags argument of ml_delete_flags(). #define ML_DEL_MESSAGE 1 // may give a "No lines in buffer" message #define ML_DEL_UNDO 2 // called from undo, do not update textprops + #define ML_DEL_NOPROP 4 // splitting data block, do not update textprops // Values for the flags argument of ml_append_int(). #define ML_APPEND_NEW 1 // starting to edit a new file *** ../vim-8.2.3061/src/memline.c 2021-06-21 21:08:04.928547486 +0200 --- src/memline.c 2021-06-27 13:00:39.630981733 +0200 *************** *** 3662,3668 **** #ifdef FEAT_PROP_POPUP // If there are text properties, make a copy, so that we can update // properties in preceding and following lines. ! if (buf->b_has_textprop && !(flags & ML_DEL_UNDO)) { size_t textlen = STRLEN((char_u *)dp + line_start) + 1; --- 3662,3668 ---- #ifdef FEAT_PROP_POPUP // If there are text properties, make a copy, so that we can update // properties in preceding and following lines. ! if (buf->b_has_textprop && !(flags & (ML_DEL_UNDO | ML_DEL_NOPROP))) { size_t textlen = STRLEN((char_u *)dp + line_start) + 1; *************** *** 3765,3773 **** { // Adjust text properties in the line above and below. if (lnum > 1) ! adjust_text_props_for_delete(buf, lnum - 1, textprop_save, textprop_save_len, TRUE); if (lnum <= buf->b_ml.ml_line_count) ! adjust_text_props_for_delete(buf, lnum, textprop_save, textprop_save_len, FALSE); } vim_free(textprop_save); #endif --- 3765,3775 ---- { // Adjust text properties in the line above and below. if (lnum > 1) ! adjust_text_props_for_delete(buf, lnum - 1, textprop_save, ! textprop_save_len, TRUE); if (lnum <= buf->b_ml.ml_line_count) ! adjust_text_props_for_delete(buf, lnum, textprop_save, ! textprop_save_len, FALSE); } vim_free(textprop_save); #endif *************** *** 4021,4027 **** | ML_APPEND_NOPROP #endif ); ! (void)ml_delete_int(buf, lnum, 0); } } vim_free(new_line); --- 4023,4029 ---- | ML_APPEND_NOPROP #endif ); ! (void)ml_delete_int(buf, lnum, ML_DEL_NOPROP); } } vim_free(new_line); *** ../vim-8.2.3061/src/testdir/test_textprop.vim 2021-05-26 22:32:06.254066656 +0200 --- src/testdir/test_textprop.vim 2021-06-27 13:02:41.610662401 +0200 *************** *** 1488,1492 **** --- 1488,1514 ---- prop_type_delete('someprop') enddef + " This was calling ml_delete_int() and try to change text properties. + def Test_prop_add_delete_line() + new + var a = 10 + var b = 20 + repeat([''], a)->append('$') + prop_type_add('Test', {highlight: 'ErrorMsg'}) + for lnum in range(1, a) + for col in range(1, b) + prop_add(1, 1, {end_lnum: lnum, end_col: col, type: 'Test'}) + endfor + endfor + + # check deleting lines is OK + :5del + :1del + :$del + + prop_type_delete('Test') + bwipe! + enddef + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.3061/src/version.c 2021-06-27 12:07:12.444471041 +0200 --- src/version.c 2021-06-27 13:03:40.186509115 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3062, /**/ -- Despite the cost of living, have you noticed how it remains so popular? /// 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 ///