Skip to content

Commit 0d4d9ee

Browse files
committed
patch 8.2.3270: prop_find() finds property with ID -2
Problem: prop_find() finds property with ID -2. Solution: Use a separate flag to indicate an ID was specified. (issue #8674)
1 parent f78da4f commit 0d4d9ee

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/textprop.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,8 @@ f_prop_find(typval_T *argvars, typval_T *rettv)
623623
int lnum_start;
624624
int start_pos_has_prop = 0;
625625
int seen_end = 0;
626-
int id = -1;
626+
int id = 0;
627+
int id_found = FALSE;
627628
int type_id = -1;
628629
int skipstart = 0;
629630
int lnum = -1;
@@ -688,8 +689,7 @@ f_prop_find(typval_T *argvars, typval_T *rettv)
688689
if (dict_find(dict, (char_u *)"id", -1) != NULL)
689690
{
690691
id = dict_get_number(dict, (char_u *)"id");
691-
if (id == -1)
692-
id = -2;
692+
id_found = id != 0;
693693
}
694694
if (dict_find(dict, (char_u *)"type", -1))
695695
{
@@ -701,12 +701,12 @@ f_prop_find(typval_T *argvars, typval_T *rettv)
701701
type_id = type->pt_id;
702702
}
703703
both = dict_get_bool(dict, (char_u *)"both", FALSE);
704-
if (id == -1 && type_id == -1)
704+
if (!id_found && type_id == -1)
705705
{
706706
emsg(_("E968: Need at least one of 'id' or 'type'"));
707707
return;
708708
}
709-
if (both && (id == -1 || type_id == -1))
709+
if (both && (!id_found || type_id == -1))
710710
{
711711
emsg(_("E860: Need 'id' and 'type' with 'both'"));
712712
return;
@@ -744,7 +744,8 @@ f_prop_find(typval_T *argvars, typval_T *rettv)
744744
continue;
745745
}
746746
if (both ? prop.tp_id == id && prop.tp_type == type_id
747-
: prop.tp_id == id || prop.tp_type == type_id)
747+
: (id_found && prop.tp_id == id)
748+
|| prop.tp_type == type_id)
748749
{
749750
// Check if the starting position has text props.
750751
if (lnum_start == lnum

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3270,
758760
/**/
759761
3269,
760762
/**/

0 commit comments

Comments
 (0)