summaryrefslogtreecommitdiffstats
path: root/src/textprop.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-12-19 13:31:06 +0000
committerBram Moolenaar <Bram@vim.org>2022-12-19 13:31:06 +0000
commit4ce1f99a2d58b809ab5a5c602bd031426f8527e8 (patch)
tree557dfdf60433feee20ea24ae7fc8fbde67e26c59 /src/textprop.c
parent8efdcee02ed02cf9e51e1757441715c2479757ee (diff)
patch 9.0.1077: can add text property with negative ID before virtual textv9.0.1077
Problem: Can add text property with negative ID before virtual text property. Solution: Remember that a text property with a negative ID was used and give an appropriate error message. (closes #11725) Fix index computation.
Diffstat (limited to 'src/textprop.c')
-rw-r--r--src/textprop.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/textprop.c b/src/textprop.c
index c1fc34e0ea..a9778b547f 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -424,6 +424,10 @@ get_textprop_id(buf_T *buf)
return -(buf->b_textprop_text.ga_len + 1);
}
+// Flag that is set when a negative ID isused for a normal text property.
+// It is then impossible to use virtual text properties.
+static int did_use_negative_pop_id = FALSE;
+
/*
* Shared between prop_add() and popup_create().
* "dict_arg" is the function argument of a dict containing "bufnr".
@@ -576,13 +580,25 @@ prop_add_common(
if (dict_arg != NULL && get_bufnr_from_arg(dict_arg, &buf) == FAIL)
goto theend;
- if (id < 0 && buf->b_textprop_text.ga_len > 0)
+ if (id < 0)
{
- emsg(_(e_cannot_use_negative_id_after_adding_textprop_with_text));
- goto theend;
+ if (buf->b_textprop_text.ga_len > 0)
+ {
+ emsg(_(e_cannot_use_negative_id_after_adding_textprop_with_text));
+ goto theend;
+ }
+ did_use_negative_pop_id = TRUE;
}
+
if (text != NULL)
+ {
+ if (did_use_negative_pop_id)
+ {
+ emsg(_(e_cannot_add_textprop_with_text_after_using_textprop_with_negative_id));
+ goto theend;
+ }
id = get_textprop_id(buf);
+ }
// This must be done _before_ we add the property because property changes
// trigger buffer (memline) reorganisation, which needs this flag to be