]> granicus.if.org Git - vim/commitdiff
patch 8.2.3272: cannot use id zero with prop_find() v8.2.3272
authorBram Moolenaar <Bram@vim.org>
Sun, 1 Aug 2021 19:30:12 +0000 (21:30 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 1 Aug 2021 19:30:12 +0000 (21:30 +0200)
Problem:    Cannot use id zero with prop_find(). (Naohiro Ono)
Solution:   Also accept id zero.

src/testdir/test_textprop.vim
src/textprop.c
src/version.c

index 0ac4e898fc3f7e24b7a38d86cd267483a2609afe..acdbf48493f8c17f48509fc1a6c900512acc4ea2 100644 (file)
@@ -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
 
index e5cc366b621fcb4209333fd1ce02d3054beea7cb..6c9d5c8c4f92ec64668706fc8316493bd8d0b8ec 100644 (file)
@@ -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))
     {
index de4d26bd5e155f54a49e01472aac8910afdd54c1..ba58b2399415f515aefb10936392428ac2916a5f 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3272,
 /**/
     3271,
 /**/