comparison src/textprop.c @ 16682:7847d281cbbf v8.1.1343

patch 8.1.1343: text properties not adjusted for Visual block mode delete commit https://github.com/vim/vim/commit/8055d17388736421d875dd4933c4c93d49a2ab58 Author: Bram Moolenaar <Bram@vim.org> Date: Fri May 17 22:57:26 2019 +0200 patch 8.1.1343: text properties not adjusted for Visual block mode delete Problem: Text properties not adjusted for Visual block mode delete. Solution: Call adjust_prop_columns(). (closes https://github.com/vim/vim/issues/4384)
author Bram Moolenaar <Bram@vim.org>
date Fri, 17 May 2019 23:00:05 +0200
parents 6f453673eb19
children 23af483c4ceb
comparison
equal deleted inserted replaced
16681:12218ecea336 16682:7847d281cbbf
955 /* 955 /*
956 * Adjust the columns of text properties in line "lnum" after position "col" to 956 * Adjust the columns of text properties in line "lnum" after position "col" to
957 * shift by "bytes_added" (can be negative). 957 * shift by "bytes_added" (can be negative).
958 * Note that "col" is zero-based, while tp_col is one-based. 958 * Note that "col" is zero-based, while tp_col is one-based.
959 * Only for the current buffer. 959 * Only for the current buffer.
960 * Called is expected to check b_has_textprop and "bytes_added" being non-zero. 960 * Caller is expected to check b_has_textprop and "bytes_added" being non-zero.
961 */ 961 */
962 void 962 void
963 adjust_prop_columns( 963 adjust_prop_columns(
964 linenr_T lnum, 964 linenr_T lnum,
965 colnr_T col, 965 colnr_T col,
992 ? (tmp_prop.tp_col >= col 992 ? (tmp_prop.tp_col >= col
993 + (pt != NULL && (pt->pt_flags & PT_FLAG_INS_START_INCL) 993 + (pt != NULL && (pt->pt_flags & PT_FLAG_INS_START_INCL)
994 ? 2 : 1)) 994 ? 2 : 1))
995 : (tmp_prop.tp_col > col + 1)) 995 : (tmp_prop.tp_col > col + 1))
996 { 996 {
997 tmp_prop.tp_col += bytes_added; 997 if (tmp_prop.tp_col + bytes_added < col + 1)
998 {
999 tmp_prop.tp_len += (tmp_prop.tp_col - 1 - col) + bytes_added;
1000 tmp_prop.tp_col = col + 1;
1001 }
1002 else
1003 tmp_prop.tp_col += bytes_added;
998 dirty = TRUE; 1004 dirty = TRUE;
1005 if (tmp_prop.tp_len <= 0)
1006 continue; // drop this text property
999 } 1007 }
1000 else if (tmp_prop.tp_len > 0 1008 else if (tmp_prop.tp_len > 0
1001 && tmp_prop.tp_col + tmp_prop.tp_len > col 1009 && tmp_prop.tp_col + tmp_prop.tp_len > col
1002 + ((pt != NULL && (pt->pt_flags & PT_FLAG_INS_END_INCL)) 1010 + ((pt != NULL && (pt->pt_flags & PT_FLAG_INS_END_INCL))
1003 ? 0 : 1)) 1011 ? 0 : 1))
1004 { 1012 {
1005 tmp_prop.tp_len += bytes_added; 1013 int after = col - bytes_added
1014 - (tmp_prop.tp_col - 1 + tmp_prop.tp_len);
1015 if (after > 0)
1016 tmp_prop.tp_len += bytes_added + after;
1017 else
1018 tmp_prop.tp_len += bytes_added;
1006 dirty = TRUE; 1019 dirty = TRUE;
1007 if (tmp_prop.tp_len <= 0) 1020 if (tmp_prop.tp_len <= 0)
1008 continue; // drop this text property 1021 continue; // drop this text property
1009 } 1022 }
1010 mch_memmove(props + wi * sizeof(textprop_T), &tmp_prop, 1023 mch_memmove(props + wi * sizeof(textprop_T), &tmp_prop,