From 0d534d9cf2ae95fc85ef7fe048d9ff590586a6a6 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sat, 21 May 2022 11:20:42 +0100 Subject: patch 8.2.4988: textprop in wrong position when replacing multi-byte chars Problem: Textprop in wrong position when replacing multi-byte chars. Solution: Adjust textprop position. (closes #10461) --- src/change.c | 7 ++++++- src/testdir/test_textprop.vim | 7 +++++++ src/version.c | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/change.c b/src/change.c index 47411ca59..2d01f9258 100644 --- a/src/change.c +++ b/src/change.c @@ -1118,7 +1118,12 @@ ins_char_bytes(char_u *buf, int charlen) ml_replace(lnum, newp, FALSE); // mark the buffer as changed and prepare for displaying - inserted_bytes(lnum, col, newlen - oldlen); + changed_bytes(lnum, col); +#ifdef FEAT_PROP_POPUP + if (curbuf->b_has_textprop && newlen != oldlen) + adjust_prop_columns(lnum, col, newlen - oldlen, + State & REPLACE_FLAG ? APC_SUBSTITUTE : 0); +#endif // If we're in Insert or Replace mode and 'showmatch' is set, then briefly // show the match for right parens and braces. diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim index 3203305e8..c29c10b27 100644 --- a/src/testdir/test_textprop.vim +++ b/src/testdir/test_textprop.vim @@ -573,6 +573,13 @@ func Test_prop_replace() call assert_equal('yyyex xyyoxx', getline(1)) call assert_equal(expected, prop_list(1)) + " Replace three 1-byte chars with three 2-byte ones. + exe "normal 0l3rø" + call assert_equal('yøøøx xyyoxx', getline(1)) + let expected[0].length += 3 + let expected[1].col += 3 + call assert_equal(expected, prop_list(1)) + call DeletePropTypes() bwipe! set bs& diff --git a/src/version.c b/src/version.c index 708f4a8ed..ec25334d3 100644 --- a/src/version.c +++ b/src/version.c @@ -746,6 +746,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4988, /**/ 4987, /**/ -- cgit v1.2.1