comparison 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
comparison
equal deleted inserted replaced
25391:df2096e6825e 25392:b427a26b0210
138 return FAIL; 138 return FAIL;
139 } 139 }
140 if (arg->vval.v_dict == NULL) 140 if (arg->vval.v_dict == NULL)
141 return OK; // NULL dict is like an empty dict 141 return OK; // NULL dict is like an empty dict
142 di = dict_find(arg->vval.v_dict, (char_u *)"bufnr", -1); 142 di = dict_find(arg->vval.v_dict, (char_u *)"bufnr", -1);
143 if (di != NULL) 143 if (di != NULL && (di->di_tv.v_type != VAR_NUMBER
144 || di->di_tv.vval.v_number != 0))
144 { 145 {
145 *buf = get_buf_arg(&di->di_tv); 146 *buf = get_buf_arg(&di->di_tv);
146 if (*buf == NULL) 147 if (*buf == NULL)
147 return FAIL; 148 return FAIL;
148 } 149 }
504 */ 505 */
505 static void 506 static void
506 prop_fill_dict(dict_T *dict, textprop_T *prop, buf_T *buf) 507 prop_fill_dict(dict_T *dict, textprop_T *prop, buf_T *buf)
507 { 508 {
508 proptype_T *pt; 509 proptype_T *pt;
510 int buflocal = TRUE;
509 511
510 dict_add_number(dict, "col", prop->tp_col); 512 dict_add_number(dict, "col", prop->tp_col);
511 dict_add_number(dict, "length", prop->tp_len); 513 dict_add_number(dict, "length", prop->tp_len);
512 dict_add_number(dict, "id", prop->tp_id); 514 dict_add_number(dict, "id", prop->tp_id);
513 dict_add_number(dict, "start", !(prop->tp_flags & TP_FLAG_CONT_PREV)); 515 dict_add_number(dict, "start", !(prop->tp_flags & TP_FLAG_CONT_PREV));
514 dict_add_number(dict, "end", !(prop->tp_flags & TP_FLAG_CONT_NEXT)); 516 dict_add_number(dict, "end", !(prop->tp_flags & TP_FLAG_CONT_NEXT));
515 pt = text_prop_type_by_id(buf, prop->tp_type); 517
518 pt = find_type_by_id(buf->b_proptypes, prop->tp_type);
519 if (pt == NULL)
520 {
521 pt = find_type_by_id(global_proptypes, prop->tp_type);
522 buflocal = FALSE;
523 }
516 if (pt != NULL) 524 if (pt != NULL)
517 dict_add_string(dict, "type", pt->pt_name); 525 dict_add_string(dict, "type", pt->pt_name);
526
527 if (buflocal)
528 dict_add_number(dict, "type_bufnr", buf->b_fnum);
529 else
530 dict_add_number(dict, "type_bufnr", 0);
518 } 531 }
519 532
520 /* 533 /*
521 * Find a property type by ID in "buf" or globally. 534 * Find a property type by ID in "buf" or globally.
522 * Returns NULL if not found. 535 * Returns NULL if not found.
1157 vim_free(prop); 1170 vim_free(prop);
1158 } 1171 }
1159 } 1172 }
1160 1173
1161 /* 1174 /*
1162 * prop_type_get({name} [, {bufnr}]) 1175 * prop_type_get({name} [, {props}])
1163 */ 1176 */
1164 void 1177 void
1165 f_prop_type_get(typval_T *argvars, typval_T *rettv) 1178 f_prop_type_get(typval_T *argvars, typval_T *rettv)
1166 { 1179 {
1167 char_u *name; 1180 char_u *name;