summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-08-01 19:28:15 +0200
committerBram Moolenaar <Bram@vim.org>2021-08-01 19:28:15 +0200
commit0d4d9ee9bb18f89d76c67f037baebe2c2db545f0 (patch)
tree7063335b7972eb55ac85bfa000f388550c485bc2
parentf78da4f9d6daf1907e4ce4be74146375dbd9a546 (diff)
downloadvim-git-8.2.3270.tar.gz
patch 8.2.3270: prop_find() finds property with ID -2v8.2.3270
Problem: prop_find() finds property with ID -2. Solution: Use a separate flag to indicate an ID was specified. (issue #8674)
-rw-r--r--src/textprop.c13
-rw-r--r--src/version.c2
2 files changed, 9 insertions, 6 deletions
diff --git a/src/textprop.c b/src/textprop.c
index bc27aef6e..e5cc366b6 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -623,7 +623,8 @@ f_prop_find(typval_T *argvars, typval_T *rettv)
int lnum_start;
int start_pos_has_prop = 0;
int seen_end = 0;
- int id = -1;
+ int id = 0;
+ int id_found = FALSE;
int type_id = -1;
int skipstart = 0;
int lnum = -1;
@@ -688,8 +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");
- if (id == -1)
- id = -2;
+ id_found = id != 0;
}
if (dict_find(dict, (char_u *)"type", -1))
{
@@ -701,12 +701,12 @@ f_prop_find(typval_T *argvars, typval_T *rettv)
type_id = type->pt_id;
}
both = dict_get_bool(dict, (char_u *)"both", FALSE);
- if (id == -1 && type_id == -1)
+ if (!id_found && type_id == -1)
{
emsg(_("E968: Need at least one of 'id' or 'type'"));
return;
}
- if (both && (id == -1 || type_id == -1))
+ if (both && (!id_found || type_id == -1))
{
emsg(_("E860: Need 'id' and 'type' with 'both'"));
return;
@@ -744,7 +744,8 @@ f_prop_find(typval_T *argvars, typval_T *rettv)
continue;
}
if (both ? prop.tp_id == id && prop.tp_type == type_id
- : prop.tp_id == id || prop.tp_type == type_id)
+ : (id_found && prop.tp_id == id)
+ || prop.tp_type == type_id)
{
// Check if the starting position has text props.
if (lnum_start == lnum
diff --git a/src/version.c b/src/version.c
index e1e1f8310..3f2266361 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 */
/**/
+ 3270,
+/**/
3269,
/**/
3268,