diff options
author | Martin Tournoij <martin@arp242.net> | 2021-07-28 13:30:16 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-07-28 13:30:16 +0200 |
commit | e2390c7f32879ab7942adf0d38b1db34933695fa (patch) | |
tree | 790c45a98865cb220c0d36d235826d5640613ad5 /src/textprop.c | |
parent | 7e6a2a64f09df577f29e024c1d1e6733d6bc1b7c (diff) | |
download | vim-git-e2390c7f32879ab7942adf0d38b1db34933695fa.tar.gz |
patch 8.2.3233: prop_list() and prop_find() do not indicate the bufferv8.2.3233
Problem: prop_list() and prop_find() do not indicate the buffer for the
used type.
Solution: Add "type_bufnr" to the results. (closes #8647)
Diffstat (limited to 'src/textprop.c')
-rw-r--r-- | src/textprop.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/textprop.c b/src/textprop.c index 4cde75544..92dc645b0 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -140,7 +140,8 @@ get_bufnr_from_arg(typval_T *arg, buf_T **buf) if (arg->vval.v_dict == NULL) return OK; // NULL dict is like an empty dict di = dict_find(arg->vval.v_dict, (char_u *)"bufnr", -1); - if (di != NULL) + if (di != NULL && (di->di_tv.v_type != VAR_NUMBER + || di->di_tv.vval.v_number != 0)) { *buf = get_buf_arg(&di->di_tv); if (*buf == NULL) @@ -506,15 +507,27 @@ find_type_by_id(hashtab_T *ht, int id) prop_fill_dict(dict_T *dict, textprop_T *prop, buf_T *buf) { proptype_T *pt; + int buflocal = TRUE; dict_add_number(dict, "col", prop->tp_col); dict_add_number(dict, "length", prop->tp_len); dict_add_number(dict, "id", prop->tp_id); dict_add_number(dict, "start", !(prop->tp_flags & TP_FLAG_CONT_PREV)); dict_add_number(dict, "end", !(prop->tp_flags & TP_FLAG_CONT_NEXT)); - pt = text_prop_type_by_id(buf, prop->tp_type); + + pt = find_type_by_id(buf->b_proptypes, prop->tp_type); + if (pt == NULL) + { + pt = find_type_by_id(global_proptypes, prop->tp_type); + buflocal = FALSE; + } if (pt != NULL) dict_add_string(dict, "type", pt->pt_name); + + if (buflocal) + dict_add_number(dict, "type_bufnr", buf->b_fnum); + else + dict_add_number(dict, "type_bufnr", 0); } /* @@ -1159,7 +1172,7 @@ f_prop_type_delete(typval_T *argvars, typval_T *rettv UNUSED) } /* - * prop_type_get({name} [, {bufnr}]) + * prop_type_get({name} [, {props}]) */ void f_prop_type_get(typval_T *argvars, typval_T *rettv) |