summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-01-04 18:07:24 +0100
committerBram Moolenaar <Bram@vim.org>2019-01-04 18:07:24 +0100
commit21b5038e02306ce2fd438249055eed372befe51f (patch)
tree6d84ecc6531ca6c594ab9310a2cd45cbcee21b91
parent7f1664e392388fd38c8b154389167ad1bdedff66 (diff)
downloadvim-git-8.1.0690.tar.gz
patch 8.1.0690: setline() and setbufline() do not clear text propertiesv8.1.0690
Problem: setline() and setbufline() do not clear text properties. Solution: Clear text properties when setting the text.
-rw-r--r--src/evalfunc.c6
-rw-r--r--src/testdir/test_textprop.vim29
-rw-r--r--src/version.c2
3 files changed, 35 insertions, 2 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 8e530f43e..58f58060e 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -1357,8 +1357,10 @@ set_buffer_lines(
if (!append && lnum <= curbuf->b_ml.ml_line_count)
{
- /* existing line, replace it */
- if (u_savesub(lnum) == OK && ml_replace(lnum, line, TRUE) == OK)
+ // Existing line, replace it.
+ // Removes any existing text properties.
+ if (u_savesub(lnum) == OK && ml_replace_len(
+ lnum, line, (colnr_T)STRLEN(line) + 1, TRUE, TRUE) == OK)
{
changed_bytes(lnum, 0);
if (is_curbuf && lnum == curwin->w_cursor.lnum)
diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim
index ac9967e94..d5069d4a7 100644
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -261,6 +261,35 @@ func Test_prop_clear_buf()
bwipe!
endfunc
+func Test_prop_setline()
+ new
+ call AddPropTypes()
+ call SetupPropsInFirstLine()
+ call assert_equal(s:expected_props, prop_list(1))
+
+ call setline(1, 'foobar')
+ call assert_equal([], prop_list(1))
+
+ call DeletePropTypes()
+ bwipe!
+endfunc
+
+func Test_prop_setbufline()
+ new
+ call AddPropTypes()
+ call SetupPropsInFirstLine()
+ let bufnr = bufnr('')
+ wincmd w
+ call assert_equal(s:expected_props, prop_list(1, {'bufnr': bufnr}))
+
+ call setbufline(bufnr, 1, 'foobar')
+ call assert_equal([], prop_list(1, {'bufnr': bufnr}))
+
+ wincmd w
+ call DeletePropTypes()
+ bwipe!
+endfunc
+
" Setup a three line prop in lines 2 - 4.
" Add short props in line 1 and 5.
func Setup_three_line_prop()
diff --git a/src/version.c b/src/version.c
index 4b7c9ae35..8e14a2e29 100644
--- a/src/version.c
+++ b/src/version.c
@@ -800,6 +800,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 690,
+/**/
689,
/**/
688,