Mercurial > vim
changeset 25441:e06540cc3371 v8.2.3257
patch 8.2.3257: calling prop_find() with -1 for ID gives errornous error
Commit: https://github.com/vim/vim/commit/8e3fc135e884a30620fb1c6e84986fae1467acd3
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jul 31 18:33:57 2021 +0200
patch 8.2.3257: calling prop_find() with -1 for ID gives errornous error
Problem: Calling prop_find() with -1 for ID gives errornous error. (Naohiro
Ono)
Solution: When passing -1 use -2. (closes #8674)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 31 Jul 2021 18:45:03 +0200 |
parents | b36a3efee848 |
children | 18d91a0274aa |
files | src/testdir/test_textprop.vim src/textprop.c src/version.c |
diffstat | 3 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/testdir/test_textprop.vim +++ b/src/testdir/test_textprop.vim @@ -239,6 +239,9 @@ 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. + call assert_equal({}, prop_find({'id': -1})) + call prop_clear(1,6) call prop_type_delete('prop_name')
--- a/src/textprop.c +++ b/src/textprop.c @@ -686,7 +686,11 @@ f_prop_find(typval_T *argvars, typval_T skipstart = dict_get_bool(dict, (char_u *)"skipstart", 0); if (dict_find(dict, (char_u *)"id", -1) != NULL) + { id = dict_get_number(dict, (char_u *)"id"); + if (id == -1) + id = -2; + } if (dict_find(dict, (char_u *)"type", -1)) { char_u *name = dict_get_string(dict, (char_u *)"type", FALSE);