Mercurial > vim
diff src/textprop.c @ 24252:7422f2f719a3 v8.2.2667
patch 8.2.2667: prop_find() cannot find item matching both id and type
Commit: https://github.com/vim/vim/commit/24f21fdfca294fec25861343f8928f6480da95f4
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 27 22:07:29 2021 +0100
patch 8.2.2667: prop_find() cannot find item matching both id and type
Problem: prop_find() cannot find item matching both id and type.
Solution: Add the "both" argument. (Naohiro Ono, closes https://github.com/vim/vim/issues/8019)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 27 Mar 2021 22:15:03 +0100 |
parents | 55631f8e0730 |
children | 09e64e81c473 |
line wrap: on
line diff
--- a/src/textprop.c +++ b/src/textprop.c @@ -600,6 +600,7 @@ f_prop_find(typval_T *argvars, typval_T int lnum = -1; int col = -1; int dir = 1; // 1 = forward, -1 = backward + int both; if (argvars[0].v_type != VAR_DICT || argvars[0].vval.v_dict == NULL) { @@ -661,11 +662,17 @@ f_prop_find(typval_T *argvars, typval_T return; type_id = type->pt_id; } + both = dict_get_bool(dict, (char_u *)"both", FALSE); 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; + } lnum_start = lnum; @@ -698,7 +705,8 @@ f_prop_find(typval_T *argvars, typval_T else if (prop.tp_col + prop.tp_len - (prop.tp_len != 0) < col) continue; } - if (prop.tp_id == id || prop.tp_type == type_id) + if (both ? prop.tp_id == id && prop.tp_type == type_id + : prop.tp_id == id || prop.tp_type == type_id) { // Check if the starting position has text props. if (lnum_start == lnum