diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-08-07 14:55:14 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-08-07 14:55:14 +0100 |
commit | ecb00c7b613b92ffb628a5a7f303ba06780288ad (patch) | |
tree | eae8ce714e3497d9a38fb46b4c78ce70de381200 | |
parent | 73c3842fa54aa99e59b897b6ff1e69e800fe9cd3 (diff) | |
download | vim-git-ecb00c7b613b92ffb628a5a7f303ba06780288ad.tar.gz |
patch 9.0.0163: text property not adjusted for text inserted with "p"v9.0.0163
Problem: Text property not adjusted for text inserted with "p".
Solution: Adjust column and length of text properties.
-rw-r--r-- | src/register.c | 3 | ||||
-rw-r--r-- | src/testdir/test_textprop.vim | 30 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 34 insertions, 1 deletions
diff --git a/src/register.c b/src/register.c index 55787df4e..f34a0ddbb 100644 --- a/src/register.c +++ b/src/register.c @@ -2101,6 +2101,8 @@ do_put( STRMOVE(ptr, oldp + col); ml_replace(lnum, newp, FALSE); + inserted_bytes(lnum, col, totlen); + // compute the byte offset for the last character first_byte_off = mb_head_off(newp, ptr - 1); @@ -2128,7 +2130,6 @@ do_put( ++curwin->w_cursor.col; else curwin->w_cursor.col -= first_byte_off; - changed_bytes(lnum, col); } else { diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim index 653db4415..61e859827 100644 --- a/src/testdir/test_textprop.vim +++ b/src/testdir/test_textprop.vim @@ -658,6 +658,36 @@ func Test_prop_open_line() set bs& endfunc +func Test_prop_put() + new + let expected = SetupOneLine() " 'xonex xtwoxx' + + let @a = 'new' + " insert just after the prop + normal 03l"ap + " insert inside the prop + normal 02l"ap + " insert just before the prop + normal 0"ap + + call assert_equal('xnewonnewenewx xtwoxx', getline(1)) + let expected[0].col += 3 + let expected[0].length += 3 + let expected[1].col += 9 + call assert_equal(expected, prop_list(1)) + + " Visually select 4 chars in the prop and put "AB" to replace them + let @a = 'AB' + normal 05lv3l"ap + call assert_equal('xnewoABenewx xtwoxx', getline(1)) + let expected[0].length -= 2 + let expected[1].col -= 2 + call assert_equal(expected, prop_list(1)) + + call DeletePropTypes() + bwipe! +endfunc + func Test_prop_clear() new call AddPropTypes() diff --git a/src/version.c b/src/version.c index 7bd94b000..9207b7f69 100644 --- a/src/version.c +++ b/src/version.c @@ -736,6 +736,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 163, +/**/ 162, /**/ 161, |