comparison 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
comparison
equal deleted inserted replaced
20582:49d2f01322db 20583:d067be761cd7
3418 { 3418 {
3419 int did_get_line = FALSE; 3419 int did_get_line = FALSE;
3420 int done_del; 3420 int done_del;
3421 int done_this; 3421 int done_this;
3422 textprop_T prop_del; 3422 textprop_T prop_del;
3423 textprop_T prop_this;
3424 bhdr_T *hp; 3423 bhdr_T *hp;
3425 DATA_BL *dp; 3424 DATA_BL *dp;
3426 int idx; 3425 int idx;
3427 int line_start; 3426 int line_start;
3428 long line_size; 3427 long line_size;
3449 idx = lnum - buf->b_ml.ml_locked_low; 3448 idx = lnum - buf->b_ml.ml_locked_low;
3450 line_start = ((dp->db_index[idx]) & DB_INDEX_MASK); 3449 line_start = ((dp->db_index[idx]) & DB_INDEX_MASK);
3451 if (idx == 0) // first line in block, text at the end 3450 if (idx == 0) // first line in block, text at the end
3452 line_size = dp->db_txt_end - line_start; 3451 line_size = dp->db_txt_end - line_start;
3453 else 3452 else
3454 line_size = ((dp->db_index[idx - 1]) & DB_INDEX_MASK) - line_start; 3453 line_size = ((dp->db_index[idx - 1]) & DB_INDEX_MASK)
3454 - line_start;
3455 text = (char_u *)dp + line_start; 3455 text = (char_u *)dp + line_start;
3456 textlen = STRLEN(text) + 1; 3456 textlen = STRLEN(text) + 1;
3457 if ((long)textlen >= line_size) 3457 if ((long)textlen >= line_size)
3458 { 3458 {
3459 if (above) 3459 if (above)
3464 } 3464 }
3465 this_props_len = line_size - (int)textlen; 3465 this_props_len = line_size - (int)textlen;
3466 } 3466 }
3467 3467
3468 found = FALSE; 3468 found = FALSE;
3469 for (done_this = 0; done_this < this_props_len; done_this += sizeof(textprop_T)) 3469 for (done_this = 0; done_this < this_props_len;
3470 done_this += sizeof(textprop_T))
3470 { 3471 {
3471 mch_memmove(&prop_this, text + textlen + done_del, sizeof(textprop_T)); 3472 int flag = above ? TP_FLAG_CONT_NEXT
3472 if (prop_del.tp_id == prop_this.tp_id 3473 : TP_FLAG_CONT_PREV;
3474 textprop_T prop_this;
3475
3476 mch_memmove(&prop_this, text + textlen + done_del,
3477 sizeof(textprop_T));
3478 if ((prop_this.tp_flags & flag)
3479 && prop_del.tp_id == prop_this.tp_id
3473 && prop_del.tp_type == prop_this.tp_type) 3480 && prop_del.tp_type == prop_this.tp_type)
3474 { 3481 {
3475 int flag = above ? TP_FLAG_CONT_NEXT : TP_FLAG_CONT_PREV;
3476
3477 found = TRUE; 3482 found = TRUE;
3478 if (prop_this.tp_flags & flag) 3483 prop_this.tp_flags &= ~flag;
3479 { 3484 mch_memmove(text + textlen + done_del, &prop_this,
3480 prop_this.tp_flags &= ~flag; 3485 sizeof(textprop_T));
3481 mch_memmove(text + textlen + done_del, &prop_this, sizeof(textprop_T)); 3486 break;
3482 }
3483 else if (above)
3484 internal_error("text property above deleted line does not continue");
3485 else
3486 internal_error("text property below deleted line does not continue");
3487 } 3487 }
3488 } 3488 }
3489 if (!found) 3489 if (!found)
3490 { 3490 {
3491 if (above) 3491 if (above)