0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 9.0.0244: cannot easily get the list of sourced scripts

Problem:    Cannot easily get the list of sourced scripts.
Solution:   Add the getscriptinfo() function. (Yegappan Lakshmanan,
            closes #10957)
This commit is contained in:
Yegappan Lakshmanan
2022-08-22 13:15:13 +01:00
committed by Bram Moolenaar
parent e89aeed43e
commit f768c3d19c
8 changed files with 70 additions and 8 deletions

View File

@@ -1933,6 +1933,36 @@ get_sourced_lnum(
? ((source_cookie_T *)cookie)->sourcing_lnum
: SOURCING_LNUM;
}
void
f_getscriptinfo(typval_T *argvars UNUSED, typval_T *rettv)
{
int i;
list_T *l;
if (rettv_list_alloc(rettv) == FAIL)
return;
l = rettv->vval.v_list;
for (i = 1; i <= script_items.ga_len; ++i)
{
scriptitem_T *si = SCRIPT_ITEM(i);
dict_T *d;
if (si->sn_name == NULL)
continue;
if ((d = dict_alloc()) == NULL
|| list_append_dict(l, d) == FAIL
|| dict_add_string(d, "name", si->sn_name) == FAIL
|| dict_add_number(d, "sid", i) == FAIL
|| dict_add_bool(d, "autoload",
si->sn_state == SN_STATE_NOT_LOADED) == FAIL)
return;
}
}
#endif
static char_u *