Skip to content

Commit 8902b31

Browse files
committed
patch 8.2.1714: text properties corrupted with substitute command
Problem: Text properties corrupted with substitute command. (Filipe Brandenburger) Solution: Get the changed line again after using u_savesub(). (closes #6984)
1 parent 7795bfe commit 8902b31

3 files changed

Lines changed: 19 additions & 0 deletions

File tree

src/testdir/test_textprop.vim

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,19 @@ func Test_proptype_substitute2()
11321132
bwipe!
11331133
endfunc
11341134

1135+
" This was causing property corruption.
1136+
func Test_proptype_substitute3()
1137+
new
1138+
call setline(1, ['abcxxx', 'def'])
1139+
call prop_type_add("test", {"highlight": "Search"})
1140+
call prop_add(1, 2, {"end_lnum": 2, "end_col": 2, "type": "test"})
1141+
%s/x\+$//
1142+
redraw
1143+
1144+
call prop_type_delete('test')
1145+
bwipe!
1146+
endfunc
1147+
11351148
func SaveOptions()
11361149
let d = #{tabstop: &tabstop,
11371150
\ softtabstop: &softtabstop,

src/textprop.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,6 +1349,10 @@ adjust_prop_columns(
13491349
&& u_savesub(lnum) == FAIL)
13501350
return FALSE;
13511351
dirty = TRUE;
1352+
1353+
// u_savesub() may have updated curbuf->b_ml, fetch it again
1354+
if (curbuf->b_ml.ml_line_lnum != lnum)
1355+
proplen = get_text_props(curbuf, lnum, &props, TRUE);
13521356
}
13531357
if (res.can_drop)
13541358
continue; // Drop this text property

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
1714,
753755
/**/
754756
1713,
755757
/**/

0 commit comments

Comments
 (0)