patch 8.2.2667: prop_find() cannot find item matching both id and type
Problem: prop_find() cannot find item matching both id and type.
Solution: Add the "both" argument. (Naohiro Ono, closes #8019)
diff --git a/src/textprop.c b/src/textprop.c
index 59b3d53..b626193 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -600,6 +600,7 @@
int lnum = -1;
int col = -1;
int dir = 1; // 1 = forward, -1 = backward
+ int both;
if (argvars[0].v_type != VAR_DICT || argvars[0].vval.v_dict == NULL)
{
@@ -661,11 +662,17 @@
return;
type_id = type->pt_id;
}
+ both = dict_get_bool(dict, (char_u *)"both", FALSE);
if (id == -1 && type_id == -1)
{
emsg(_("E968: Need at least one of 'id' or 'type'"));
return;
}
+ if (both && (id == -1 || type_id == -1))
+ {
+ emsg(_("E860: Need 'id' and 'type' with 'both'"));
+ return;
+ }
lnum_start = lnum;
@@ -698,7 +705,8 @@
else if (prop.tp_col + prop.tp_len - (prop.tp_len != 0) < col)
continue;
}
- if (prop.tp_id == id || prop.tp_type == type_id)
+ if (both ? prop.tp_id == id && prop.tp_type == type_id
+ : prop.tp_id == id || prop.tp_type == type_id)
{
// Check if the starting position has text props.
if (lnum_start == lnum