]> granicus.if.org Git - vim/commitdiff
patch 8.2.1714: text properties corrupted with substitute command v8.2.1714
authorBram Moolenaar <Bram@vim.org>
Sun, 20 Sep 2020 19:04:35 +0000 (21:04 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 20 Sep 2020 19:04:35 +0000 (21:04 +0200)
Problem:    Text properties corrupted with substitute command. (Filipe
            Brandenburger)
Solution:   Get the changed line again after using u_savesub(). (closes #6984)

src/testdir/test_textprop.vim
src/textprop.c
src/version.c

index 5bd7e95c3ddb14890c46f14c69c1f39b9cb1bf76..dbf393f89cfe0d2cb13c1be0958c015627c30c92 100644 (file)
@@ -1132,6 +1132,19 @@ func Test_proptype_substitute2()
   bwipe!
 endfunc
 
+" This was causing property corruption.
+func Test_proptype_substitute3()
+  new
+  call setline(1, ['abcxxx', 'def'])
+  call prop_type_add("test", {"highlight": "Search"})
+  call prop_add(1, 2, {"end_lnum": 2, "end_col": 2, "type": "test"})
+  %s/x\+$//
+  redraw
+
+  call prop_type_delete('test')
+  bwipe!
+endfunc
+
 func SaveOptions()
   let d = #{tabstop: &tabstop,
          \ softtabstop: &softtabstop,
index 639c5df8a1cc31953583a5b29c40f5c7f60595a3..bca0d9e02171400977231877faee2541df77ff6e 100644 (file)
@@ -1349,6 +1349,10 @@ adjust_prop_columns(
                                                    && u_savesub(lnum) == FAIL)
                return FALSE;
            dirty = TRUE;
+
+           // u_savesub() may have updated curbuf->b_ml, fetch it again
+           if (curbuf->b_ml.ml_line_lnum != lnum)
+               proplen = get_text_props(curbuf, lnum, &props, TRUE);
        }
        if (res.can_drop)
            continue; // Drop this text property
index a7def1b6cf8dd1d967e2876838e7332184715cad..7031d7a566523cc42423b7b8670db4796da55ab3 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1714,
 /**/
     1713,
 /**/