Mercurial > vim
diff src/memline.c @ 20583:d067be761cd7 v8.2.0845
patch 8.2.0845: text properties crossing lines not handled correctly
Commit: https://github.com/vim/vim/commit/87be9be1db6b6d8fb57ef14e05f23a84e5e8bea0
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat May 30 15:32:02 2020 +0200
patch 8.2.0845: text properties crossing lines not handled correctly
Problem: Text properties crossing lines not handled correctly.
Solution: When joining lines merge text properties if possible.
(Axel Forsman, closes #5839, closes #5683)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 30 May 2020 15:45:04 +0200 |
parents | e529690f27bc |
children | d571231175b4 |
line wrap: on
line diff
--- a/src/memline.c +++ b/src/memline.c @@ -3420,7 +3420,6 @@ adjust_text_props_for_delete( int done_del; int done_this; textprop_T prop_del; - textprop_T prop_this; bhdr_T *hp; DATA_BL *dp; int idx; @@ -3451,7 +3450,8 @@ adjust_text_props_for_delete( if (idx == 0) // first line in block, text at the end line_size = dp->db_txt_end - line_start; else - line_size = ((dp->db_index[idx - 1]) & DB_INDEX_MASK) - line_start; + line_size = ((dp->db_index[idx - 1]) & DB_INDEX_MASK) + - line_start; text = (char_u *)dp + line_start; textlen = STRLEN(text) + 1; if ((long)textlen >= line_size) @@ -3466,24 +3466,24 @@ adjust_text_props_for_delete( } found = FALSE; - for (done_this = 0; done_this < this_props_len; done_this += sizeof(textprop_T)) + for (done_this = 0; done_this < this_props_len; + done_this += sizeof(textprop_T)) { - mch_memmove(&prop_this, text + textlen + done_del, sizeof(textprop_T)); - if (prop_del.tp_id == prop_this.tp_id + int flag = above ? TP_FLAG_CONT_NEXT + : TP_FLAG_CONT_PREV; + textprop_T prop_this; + + mch_memmove(&prop_this, text + textlen + done_del, + sizeof(textprop_T)); + if ((prop_this.tp_flags & flag) + && prop_del.tp_id == prop_this.tp_id && prop_del.tp_type == prop_this.tp_type) { - int flag = above ? TP_FLAG_CONT_NEXT : TP_FLAG_CONT_PREV; - found = TRUE; - if (prop_this.tp_flags & flag) - { - prop_this.tp_flags &= ~flag; - mch_memmove(text + textlen + done_del, &prop_this, sizeof(textprop_T)); - } - else if (above) - internal_error("text property above deleted line does not continue"); - else - internal_error("text property below deleted line does not continue"); + prop_this.tp_flags &= ~flag; + mch_memmove(text + textlen + done_del, &prop_this, + sizeof(textprop_T)); + break; } } if (!found)