summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/evalfunc.c2
-rw-r--r--src/testdir/test_textprop.vim52
-rw-r--r--src/textprop.c5
-rw-r--r--src/version.c2
4 files changed, 51 insertions, 10 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index f5a0bd8b5..81264bd56 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -788,7 +788,7 @@ static struct fst
{"prop_add", 3, 3, f_prop_add},
{"prop_clear", 1, 3, f_prop_clear},
{"prop_list", 1, 2, f_prop_list},
- {"prop_remove", 2, 3, f_prop_remove},
+ {"prop_remove", 1, 3, f_prop_remove},
{"prop_type_add", 2, 2, f_prop_type_add},
{"prop_type_change", 2, 2, f_prop_type_change},
{"prop_type_delete", 1, 2, f_prop_type_delete},
diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim
index 5ea551750..eab7aaab7 100644
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -166,28 +166,64 @@ func Test_prop_add_remove_buf()
new
let bufnr = bufnr('')
call AddPropTypes()
- call setline(1, 'one two three')
+ for lnum in range(1, 4)
+ call setline(lnum, 'one two three')
+ endfor
wincmd w
- call prop_add(1, 1, {'length': 3, 'id': 11, 'type': 'one', 'bufnr': bufnr})
- call prop_add(1, 5, {'length': 3, 'id': 12, 'type': 'two', 'bufnr': bufnr})
- call prop_add(1, 11, {'length': 3, 'id': 13, 'type': 'three', 'bufnr': bufnr})
-
+ for lnum in range(1, 4)
+ call prop_add(lnum, 1, {'length': 3, 'id': 11, 'type': 'one', 'bufnr': bufnr})
+ call prop_add(lnum, 5, {'length': 3, 'id': 12, 'type': 'two', 'bufnr': bufnr})
+ call prop_add(lnum, 11, {'length': 3, 'id': 13, 'type': 'three', 'bufnr': bufnr})
+ endfor
+
let props = [
\ {'col': 1, 'length': 3, 'id': 11, 'type': 'one', 'start': 1, 'end': 1},
\ {'col': 5, 'length': 3, 'id': 12, 'type': 'two', 'start': 1, 'end': 1},
\ {'col': 11, 'length': 3, 'id': 13, 'type': 'three', 'start': 1, 'end': 1},
\]
call assert_equal(props, prop_list(1, {'bufnr': bufnr}))
-
+
" remove by id
- call prop_remove({'id': 12, 'bufnr': bufnr}, 1)
+ let before_props = deepcopy(props)
unlet props[1]
+
+ call prop_remove({'id': 12, 'bufnr': bufnr}, 1)
call assert_equal(props, prop_list(1, {'bufnr': bufnr}))
+ call assert_equal(before_props, prop_list(2, {'bufnr': bufnr}))
+ call assert_equal(before_props, prop_list(3, {'bufnr': bufnr}))
+ call assert_equal(before_props, prop_list(4, {'bufnr': bufnr}))
+
+ call prop_remove({'id': 12, 'bufnr': bufnr}, 3, 4)
+ call assert_equal(props, prop_list(1, {'bufnr': bufnr}))
+ call assert_equal(before_props, prop_list(2, {'bufnr': bufnr}))
+ call assert_equal(props, prop_list(3, {'bufnr': bufnr}))
+ call assert_equal(props, prop_list(4, {'bufnr': bufnr}))
+
+ call prop_remove({'id': 12, 'bufnr': bufnr})
+ for lnum in range(1, 4)
+ call assert_equal(props, prop_list(lnum, {'bufnr': bufnr}))
+ endfor
" remove by type
- call prop_remove({'type': 'one', 'bufnr': bufnr}, 1)
+ let before_props = deepcopy(props)
unlet props[0]
+
+ call prop_remove({'type': 'one', 'bufnr': bufnr}, 1)
+ call assert_equal(props, prop_list(1, {'bufnr': bufnr}))
+ call assert_equal(before_props, prop_list(2, {'bufnr': bufnr}))
+ call assert_equal(before_props, prop_list(3, {'bufnr': bufnr}))
+ call assert_equal(before_props, prop_list(4, {'bufnr': bufnr}))
+
+ call prop_remove({'type': 'one', 'bufnr': bufnr}, 3, 4)
call assert_equal(props, prop_list(1, {'bufnr': bufnr}))
+ call assert_equal(before_props, prop_list(2, {'bufnr': bufnr}))
+ call assert_equal(props, prop_list(3, {'bufnr': bufnr}))
+ call assert_equal(props, prop_list(4, {'bufnr': bufnr}))
+
+ call prop_remove({'type': 'one', 'bufnr': bufnr})
+ for lnum in range(1, 4)
+ call assert_equal(props, prop_list(lnum, {'bufnr': bufnr}))
+ endfor
call DeletePropTypes()
wincmd w
diff --git a/src/textprop.c b/src/textprop.c
index 674faebe2..34738adc4 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -629,7 +629,10 @@ f_prop_remove(typval_T *argvars, typval_T *rettv)
mch_memmove(newptr, buf->b_ml.ml_line_ptr,
buf->b_ml.ml_line_len);
buf->b_ml.ml_line_ptr = newptr;
- curbuf->b_ml.ml_flags |= ML_LINE_DIRTY;
+ buf->b_ml.ml_flags |= ML_LINE_DIRTY;
+
+ cur_prop = buf->b_ml.ml_line_ptr + len
+ + idx * sizeof(textprop_T);
}
taillen = buf->b_ml.ml_line_len - len
diff --git a/src/version.c b/src/version.c
index 9114570f8..bee744e87 100644
--- a/src/version.c
+++ b/src/version.c
@@ -780,6 +780,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1035,
+/**/
1034,
/**/
1033,