0
0
mirror of https://github.com/vim/vim.git synced 2025-10-06 05:44:14 -04:00

patch 8.1.1035: prop_remove() second argument is not optional

Problem:    prop_remove() second argument is not optional.
Solution:   Fix argument count.  Use "buf" instead of "curbuf". (closes #4147)
This commit is contained in:
Bram Moolenaar
2019-03-22 13:20:43 +01:00
parent 2ace1bd652
commit 0a2f578e22
4 changed files with 51 additions and 10 deletions

View File

@@ -788,7 +788,7 @@ static struct fst
{"prop_add", 3, 3, f_prop_add}, {"prop_add", 3, 3, f_prop_add},
{"prop_clear", 1, 3, f_prop_clear}, {"prop_clear", 1, 3, f_prop_clear},
{"prop_list", 1, 2, f_prop_list}, {"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_add", 2, 2, f_prop_type_add},
{"prop_type_change", 2, 2, f_prop_type_change}, {"prop_type_change", 2, 2, f_prop_type_change},
{"prop_type_delete", 1, 2, f_prop_type_delete}, {"prop_type_delete", 1, 2, f_prop_type_delete},

View File

@@ -166,11 +166,15 @@ func Test_prop_add_remove_buf()
new new
let bufnr = bufnr('') let bufnr = bufnr('')
call AddPropTypes() call AddPropTypes()
call setline(1, 'one two three') for lnum in range(1, 4)
call setline(lnum, 'one two three')
endfor
wincmd w wincmd w
call prop_add(1, 1, {'length': 3, 'id': 11, 'type': 'one', 'bufnr': bufnr}) for lnum in range(1, 4)
call prop_add(1, 5, {'length': 3, 'id': 12, 'type': 'two', 'bufnr': bufnr}) call prop_add(lnum, 1, {'length': 3, 'id': 11, 'type': 'one', 'bufnr': bufnr})
call prop_add(1, 11, {'length': 3, 'id': 13, 'type': 'three', '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 = [ let props = [
\ {'col': 1, 'length': 3, 'id': 11, 'type': 'one', 'start': 1, 'end': 1}, \ {'col': 1, 'length': 3, 'id': 11, 'type': 'one', 'start': 1, 'end': 1},
@@ -180,14 +184,46 @@ func Test_prop_add_remove_buf()
call assert_equal(props, prop_list(1, {'bufnr': bufnr})) call assert_equal(props, prop_list(1, {'bufnr': bufnr}))
" remove by id " remove by id
call prop_remove({'id': 12, 'bufnr': bufnr}, 1) let before_props = deepcopy(props)
unlet props[1] unlet props[1]
call prop_remove({'id': 12, 'bufnr': bufnr}, 1)
call assert_equal(props, prop_list(1, {'bufnr': bufnr})) 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 " remove by type
call prop_remove({'type': 'one', 'bufnr': bufnr}, 1) let before_props = deepcopy(props)
unlet props[0] unlet props[0]
call prop_remove({'type': 'one', 'bufnr': bufnr}, 1)
call assert_equal(props, prop_list(1, {'bufnr': bufnr})) 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() call DeletePropTypes()
wincmd w wincmd w

View File

@@ -629,7 +629,10 @@ f_prop_remove(typval_T *argvars, typval_T *rettv)
mch_memmove(newptr, buf->b_ml.ml_line_ptr, mch_memmove(newptr, buf->b_ml.ml_line_ptr,
buf->b_ml.ml_line_len); buf->b_ml.ml_line_len);
buf->b_ml.ml_line_ptr = newptr; 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 taillen = buf->b_ml.ml_line_len - len

View File

@@ -779,6 +779,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1035,
/**/ /**/
1034, 1034,
/**/ /**/