Patch 8.2.0357

10 views
Skip to first unread message

Bram Moolenaar

unread,
Mar 5, 2020, 3:53:37 PM3/5/20
to vim...@googlegroups.com

Patch 8.2.0357
Problem: Cannot delete a text property matching both id and type. (Axel
Forsman)
Solution: Add the "both" argument.
Files: src/textprop.c, runtime/doc/textprop.txt,
src/testdir/test_textprop.vim


*** ../vim-8.2.0356/src/textprop.c 2020-02-26 22:05:57.094386589 +0100
--- src/textprop.c 2020-03-05 21:49:48.807024399 +0100
***************
*** 796,801 ****
--- 796,802 ----
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,848 ****
--- 839,856 ----
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,874 ****
size_t taillen;

mch_memmove(&textprop, cur_prop, sizeof(textprop_T));
! if (textprop.tp_id == id || textprop.tp_type == type_id)
{
if (!(buf->b_ml.ml_flags & ML_LINE_DIRTY))
{
--- 876,883 ----
size_t taillen;

mch_memmove(&textprop, cur_prop, sizeof(textprop_T));
! 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))
{
*** ../vim-8.2.0356/runtime/doc/textprop.txt 2020-01-10 19:56:42.778995613 +0100
--- runtime/doc/textprop.txt 2020-03-05 21:38:08.713137646 +0100
***************
*** 230,235 ****
--- 231,237 ----
{props} is a dictionary with these fields:
id remove text properties with this ID
type remove text properties with this type name
+ both "id" and "type" must both match
bufnr use this buffer instead of the current one
all when TRUE remove all matching text properties,
not just the first one
*** ../vim-8.2.0356/src/testdir/test_textprop.vim 2020-02-26 22:05:57.094386589 +0100
--- src/testdir/test_textprop.vim 2020-03-05 21:51:27.366720074 +0100
***************
*** 270,275 ****
--- 270,292 ----

call DeletePropTypes()
bwipe!
+
+ new
+ call AddPropTypes()
+ call SetupPropsInFirstLine()
+ call prop_add(1, 6, {'length': 2, 'id': 11, 'type': 'three'})
+ let props = Get_expected_props()
+ call insert(props, {'col': 6, 'length': 2, 'id': 11, 'type': 'three', 'start': 1, 'end': 1}, 3)
+ call assert_equal(props, prop_list(1))
+ call assert_equal(1, prop_remove({'type': 'three', 'id': 11, 'both': 1, 'all': 1}, 1))
+ unlet props[3]
+ call assert_equal(props, prop_list(1))
+
+ call assert_fails("call prop_remove({'id': 11, 'both': 1})", 'E860')
+ call assert_fails("call prop_remove({'type': 'three', 'both': 1})", 'E860')
+
+ call DeletePropTypes()
+ bwipe!
endfunc

func SetupOneLine()
*** ../vim-8.2.0356/src/version.c 2020-03-04 23:21:32.273078877 +0100
--- src/version.c 2020-03-05 21:38:36.409032598 +0100
***************
*** 740,741 ****
--- 740,743 ----
{ /* Add new patch number below this line */
+ /**/
+ 357,
/**/


--
If Microsoft would build a car...
... The airbag system would ask "are you SURE?" before deploying.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages