summaryrefslogtreecommitdiff
path: root/src/textprop.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-03-05 21:52:55 +0100
committerBram Moolenaar <Bram@vim.org>2020-03-05 21:52:55 +0100
commit49b79bd4888341d527c95f2aa73ed953203ce2b6 (patch)
treed43e2c107c13b78845cf4e72670f696c21e88717 /src/textprop.c
parent8f027fe470555252b258508c455e93700a969cb1 (diff)
downloadvim-git-49b79bd4888341d527c95f2aa73ed953203ce2b6.tar.gz
patch 8.2.0357: cannot delete a text property matching both id and typev8.2.0357
Problem: Cannot delete a text property matching both id and type. (Axel Forsman) Solution: Add the "both" argument.
Diffstat (limited to 'src/textprop.c')
-rw-r--r--src/textprop.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/textprop.c b/src/textprop.c
index 3ad84a242..2827af437 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -796,6 +796,7 @@ f_prop_remove(typval_T *argvars, typval_T *rettv)
int do_all = FALSE;
int id = -1;
int type_id = -1;
+ int both = FALSE;
rettv->vval.v_number = 0;
if (argvars[0].v_type != VAR_DICT || argvars[0].vval.v_dict == NULL)
@@ -838,11 +839,18 @@ f_prop_remove(typval_T *argvars, typval_T *rettv)
return;
type_id = type->pt_id;
}
+ if (dict_find(dict, (char_u *)"both", -1) != NULL)
+ both = dict_get_number(dict, (char_u *)"both");
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;
+ }
if (end == 0)
end = buf->b_ml.ml_line_count;
@@ -868,7 +876,8 @@ f_prop_remove(typval_T *argvars, typval_T *rettv)
size_t taillen;
mch_memmove(&textprop, cur_prop, sizeof(textprop_T));
- if (textprop.tp_id == id || textprop.tp_type == type_id)
+ if (both ? textprop.tp_id == id && textprop.tp_type == type_id
+ : textprop.tp_id == id || textprop.tp_type == type_id)
{
if (!(buf->b_ml.ml_flags & ML_LINE_DIRTY))
{