diff 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
line wrap: on
line diff
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -957,7 +957,7 @@ clear_buf_prop_types(buf_T *buf)
  * shift by "bytes_added" (can be negative).
  * Note that "col" is zero-based, while tp_col is one-based.
  * Only for the current buffer.
- * Called is expected to check b_has_textprop and "bytes_added" being non-zero.
+ * Caller is expected to check b_has_textprop and "bytes_added" being non-zero.
  */
     void
 adjust_prop_columns(
@@ -994,15 +994,28 @@ adjust_prop_columns(
 								      ? 2 : 1))
 		: (tmp_prop.tp_col > col + 1))
 	{
-	    tmp_prop.tp_col += bytes_added;
+	    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;
+	    }
+	    else
+		tmp_prop.tp_col += bytes_added;
 	    dirty = TRUE;
+	    if (tmp_prop.tp_len <= 0)
+		continue;  // drop this text property
 	}
 	else if (tmp_prop.tp_len > 0
 		&& tmp_prop.tp_col + tmp_prop.tp_len > col
 		       + ((pt != NULL && (pt->pt_flags & PT_FLAG_INS_END_INCL))
 								      ? 0 : 1))
 	{
-	    tmp_prop.tp_len += bytes_added;
+	    int after = col - bytes_added
+				     - (tmp_prop.tp_col - 1 + tmp_prop.tp_len);
+	    if (after > 0)
+		tmp_prop.tp_len += bytes_added + after;
+	    else
+		tmp_prop.tp_len += bytes_added;
 	    dirty = TRUE;
 	    if (tmp_prop.tp_len <= 0)
 		continue;  // drop this text property