diff src/textprop.c @ 25392:b427a26b0210 v8.2.3233

patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer Commit: https://github.com/vim/vim/commit/e2390c7f32879ab7942adf0d38b1db34933695fa Author: Martin Tournoij <martin@arp242.net> Date: Wed Jul 28 13:30:16 2021 +0200 patch 8.2.3233: prop_list() and prop_find() do not indicate the buffer Problem: prop_list() and prop_find() do not indicate the buffer for the used type. Solution: Add "type_bufnr" to the results. (closes #8647)
author Bram Moolenaar <Bram@vim.org>
date Wed, 28 Jul 2021 13:45:03 +0200
parents e8e2c4d33b9b
children e06540cc3371
line wrap: on
line diff
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -140,7 +140,8 @@ get_bufnr_from_arg(typval_T *arg, buf_T 
     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, ty
 }
 
 /*
- * prop_type_get({name} [, {bufnr}])
+ * prop_type_get({name} [, {props}])
  */
     void
 f_prop_type_get(typval_T *argvars, typval_T *rettv)