Mercurial > vim
comparison src/textprop.c @ 19601:67f39cb0a49c v8.2.0357
patch 8.2.0357: cannot delete a text property matching both id and type
Commit: https://github.com/vim/vim/commit/49b79bd4888341d527c95f2aa73ed953203ce2b6
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Mar 5 21:52:55 2020 +0100
patch 8.2.0357: cannot delete a text property matching both id and type
Problem: Cannot delete a text property matching both id and type. (Axel
Forsman)
Solution: Add the "both" argument.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 05 Mar 2020 22:00:04 +0100 |
parents | 36ec10251b2b |
children | 1d493fce1fbd |
comparison
equal
deleted
inserted
replaced
19600:911eb7bbfebb | 19601:67f39cb0a49c |
---|---|
794 buf_T *buf = curbuf; | 794 buf_T *buf = curbuf; |
795 dictitem_T *di; | 795 dictitem_T *di; |
796 int do_all = FALSE; | 796 int do_all = FALSE; |
797 int id = -1; | 797 int id = -1; |
798 int type_id = -1; | 798 int type_id = -1; |
799 int both = FALSE; | |
799 | 800 |
800 rettv->vval.v_number = 0; | 801 rettv->vval.v_number = 0; |
801 if (argvars[0].v_type != VAR_DICT || argvars[0].vval.v_dict == NULL) | 802 if (argvars[0].v_type != VAR_DICT || argvars[0].vval.v_dict == NULL) |
802 { | 803 { |
803 emsg(_(e_invarg)); | 804 emsg(_(e_invarg)); |
836 | 837 |
837 if (type == NULL) | 838 if (type == NULL) |
838 return; | 839 return; |
839 type_id = type->pt_id; | 840 type_id = type->pt_id; |
840 } | 841 } |
842 if (dict_find(dict, (char_u *)"both", -1) != NULL) | |
843 both = dict_get_number(dict, (char_u *)"both"); | |
841 if (id == -1 && type_id == -1) | 844 if (id == -1 && type_id == -1) |
842 { | 845 { |
843 emsg(_("E968: Need at least one of 'id' or 'type'")); | 846 emsg(_("E968: Need at least one of 'id' or 'type'")); |
847 return; | |
848 } | |
849 if (both && (id == -1 || type_id == -1)) | |
850 { | |
851 emsg(_("E860: Need 'id' and 'type' with 'both'")); | |
844 return; | 852 return; |
845 } | 853 } |
846 | 854 |
847 if (end == 0) | 855 if (end == 0) |
848 end = buf->b_ml.ml_line_count; | 856 end = buf->b_ml.ml_line_count; |
866 char_u *cur_prop = buf->b_ml.ml_line_ptr + len | 874 char_u *cur_prop = buf->b_ml.ml_line_ptr + len |
867 + idx * sizeof(textprop_T); | 875 + idx * sizeof(textprop_T); |
868 size_t taillen; | 876 size_t taillen; |
869 | 877 |
870 mch_memmove(&textprop, cur_prop, sizeof(textprop_T)); | 878 mch_memmove(&textprop, cur_prop, sizeof(textprop_T)); |
871 if (textprop.tp_id == id || textprop.tp_type == type_id) | 879 if (both ? textprop.tp_id == id && textprop.tp_type == type_id |
880 : textprop.tp_id == id || textprop.tp_type == type_id) | |
872 { | 881 { |
873 if (!(buf->b_ml.ml_flags & ML_LINE_DIRTY)) | 882 if (!(buf->b_ml.ml_flags & ML_LINE_DIRTY)) |
874 { | 883 { |
875 char_u *newptr = alloc(buf->b_ml.ml_line_len); | 884 char_u *newptr = alloc(buf->b_ml.ml_line_len); |
876 | 885 |