diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-12-19 13:31:06 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-12-19 13:31:06 +0000 |
commit | 4ce1f99a2d58b809ab5a5c602bd031426f8527e8 (patch) | |
tree | 557dfdf60433feee20ea24ae7fc8fbde67e26c59 /src/textprop.c | |
parent | 8efdcee02ed02cf9e51e1757441715c2479757ee (diff) | |
download | vim-git-4ce1f99a2d58b809ab5a5c602bd031426f8527e8.tar.gz |
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.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/textprop.c b/src/textprop.c index c1fc34e0e..a9778b547 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 |