summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-08-01 21:30:12 +0200
committerBram Moolenaar <Bram@vim.org>2021-08-01 21:30:12 +0200
commite041dde7bb9157644fa5135a252c84924b9ea433 (patch)
tree5fa0a808d67cb5cfaf3e821999bb443c8fc64074
parente4db17fb6e2d029aa2dddfca703ace9bcf0d85fd (diff)
downloadvim-git-8.2.3272.tar.gz
patch 8.2.3272: cannot use id zero with prop_find()v8.2.3272
Problem: Cannot use id zero with prop_find(). (Naohiro Ono) Solution: Also accept id zero.
-rw-r--r--src/testdir/test_textprop.vim12
-rw-r--r--src/textprop.c2
-rw-r--r--src/version.c2
3 files changed, 12 insertions, 4 deletions
diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim
index 0ac4e898f..acdbf4849 100644
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -239,12 +239,18 @@ func Test_prop_find()
let result = prop_find({'type': 'prop_name', 'lnum': 1}, 'f')
call assert_equal(expected[0], result)
- " When ID is -1 it's like prop is not found.
+ " Negative ID is possible, just like prop is not found.
call assert_equal({}, prop_find({'id': -1}))
+ call assert_equal({}, prop_find({'id': -2}))
- call prop_clear(1,6)
- call prop_type_delete('prop_name')
+ call prop_clear(1, 6)
+
+ " Default ID is zero
+ call prop_add(5, 4, {'type': 'prop_name', 'length': 1})
+ call assert_equal(#{lnum: 5, id: 0, col: 4, type_bufnr: 0, end: 1, type: 'prop_name', length: 1, start: 1}, prop_find({'id': 0}))
+ call prop_type_delete('prop_name')
+ call prop_clear(1, 6)
bwipe!
endfunc
diff --git a/src/textprop.c b/src/textprop.c
index e5cc366b6..6c9d5c8c4 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -689,7 +689,7 @@ f_prop_find(typval_T *argvars, typval_T *rettv)
if (dict_find(dict, (char_u *)"id", -1) != NULL)
{
id = dict_get_number(dict, (char_u *)"id");
- id_found = id != 0;
+ id_found = TRUE;
}
if (dict_find(dict, (char_u *)"type", -1))
{
diff --git a/src/version.c b/src/version.c
index de4d26bd5..ba58b2399 100644
--- a/src/version.c
+++ b/src/version.c
@@ -756,6 +756,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3272,
+/**/
3271,
/**/
3270,