summaryrefslogtreecommitdiff
path: root/src/scriptfile.c
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2022-08-25 17:40:40 +0100
committerBram Moolenaar <Bram@vim.org>2022-08-25 17:40:40 +0100
commit520f6ef60a59f7b5f3da9199999d13dbe817d3ce (patch)
tree7982ec9430d2766a4f4f53066e2172f8311e328a /src/scriptfile.c
parent0166e398d11a09662d783fe5db62b414045880f8 (diff)
downloadvim-git-520f6ef60a59f7b5f3da9199999d13dbe817d3ce.tar.gz
patch 9.0.0269: getscriptinfo() does not include the versionv9.0.0269
Problem: getscriptinfo() does not include the version. Cannot select entries by script name. Solution: Add the "version" item and the "name" argument. (Yegappan Lakshmanan, closes #10962)
Diffstat (limited to 'src/scriptfile.c')
-rw-r--r--src/scriptfile.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/scriptfile.c b/src/scriptfile.c
index 1382f29d7..a2b88a65a 100644
--- a/src/scriptfile.c
+++ b/src/scriptfile.c
@@ -1946,17 +1946,35 @@ get_sourced_lnum(
: SOURCING_LNUM;
}
+/*
+ * getscriptinfo() function
+ */
void
-f_getscriptinfo(typval_T *argvars UNUSED, typval_T *rettv)
+f_getscriptinfo(typval_T *argvars, typval_T *rettv)
{
int i;
list_T *l;
+ char_u *pat = NULL;
+ regmatch_T regmatch;
if (rettv_list_alloc(rettv) == FAIL)
return;
+ if (check_for_opt_dict_arg(argvars, 0) == FAIL)
+ return;
+
l = rettv->vval.v_list;
+ regmatch.regprog = NULL;
+ regmatch.rm_ic = p_ic;
+
+ if (argvars[0].v_type == VAR_DICT)
+ {
+ pat = dict_get_string(argvars[0].vval.v_dict, "name", TRUE);
+ if (pat != NULL)
+ regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
+ }
+
for (i = 1; i <= script_items.ga_len; ++i)
{
scriptitem_T *si = SCRIPT_ITEM(i);
@@ -1965,15 +1983,23 @@ f_getscriptinfo(typval_T *argvars UNUSED, typval_T *rettv)
if (si->sn_name == NULL)
continue;
+ if (pat != NULL && regmatch.regprog != NULL
+ && !vim_regexec(&regmatch, si->sn_name, (colnr_T)0))
+ 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_number(d, "sourced", si->sn_sourced_sid) == FAIL
+ || dict_add_number(d, "version", si->sn_version) == FAIL
|| dict_add_bool(d, "autoload",
si->sn_state == SN_STATE_NOT_LOADED) == FAIL)
return;
}
+
+ vim_regfree(regmatch.regprog);
+ vim_free(pat);
}
#endif