summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2022-05-15 13:08:02 +0100
committerBram Moolenaar <Bram@vim.org>2022-05-15 13:08:02 +0100
commitb559b302e0ecc6fced03d5201dc30f10cff7af0a (patch)
tree4b42965e1ce1153a1ec471de9c7e4dcef442e920
parent395bd1f6d3edc9f7edb5d1f2d7deaf5a9e3ab93c (diff)
patch 8.2.4957: text properties in a wrong position after a block changev8.2.4957
Problem: Text properties in a wrong position after a block change. Solution: Adjust the properties columns. (closes #10427)
-rw-r--r--src/ops.c6
-rw-r--r--src/testdir/test_textprop.vim33
-rw-r--r--src/version.c2
3 files changed, 41 insertions, 0 deletions
diff --git a/src/ops.c b/src/ops.c
index b11cbf5416..5b4c2957bc 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -1814,6 +1814,12 @@ op_change(oparg_T *oap)
oldp += bd.textcol;
STRMOVE(newp + offset, oldp);
ml_replace(linenr, newp, FALSE);
+#ifdef FEAT_PROP_POPUP
+ // Shift the properties for linenr as edit() would do.
+ if (curbuf->b_has_textprop)
+ adjust_prop_columns(linenr, bd.textcol,
+ vpos.coladd + ins_len, 0);
+#endif
}
}
check_cursor();
diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim
index 50012acaf8..8e12041427 100644
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -2003,4 +2003,37 @@ func Test_prop_insert_multiline()
bwipe!
endfunc
+func Test_prop_blockwise_change()
+ new
+ call AddPropTypes()
+
+ call setline(1, ['foooooo', 'bar', 'baaaaz'])
+ call prop_add(1, 1, #{end_col: 3, type: 'one'})
+ call prop_add(2, 1, #{end_col: 3, type: 'two'})
+ call prop_add(3, 1, #{end_col: 3, type: 'three'})
+
+ " Replace the first two columns with '123', since 'start_incl' is false the
+ " prop is not extended.
+ call feedkeys("gg\<c-v>2jc123\<Esc>", 'nxt')
+
+ let lines =<< trim END
+ 123oooooo
+ 123ar
+ 123aaaaz
+ END
+ call assert_equal(lines, getline(1, '$'))
+ let expected = [
+ \ {'lnum': 1, 'id': 0, 'col': 4, 'type_bufnr': 0, 'end': 1, 'type': 'one',
+ \ 'length': 1, 'start': 1},
+ \ {'lnum': 2, 'id': 0, 'col': 4, 'type_bufnr': 0, 'end': 1, 'type': 'two',
+ \ 'length': 1, 'start': 1},
+ \ {'lnum': 3, 'id': 0, 'col': 4, 'type_bufnr': 0, 'end': 1 ,
+ \ 'type': 'three', 'length': 1, 'start': 1}
+ \ ]
+ call assert_equal(expected, prop_list(1, #{end_lnum: 10}))
+
+ call DeletePropTypes()
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 821f3680e2..711349a35f 100644
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4957,
+/**/
4956,
/**/
4955,