mirror of
https://github.com/neovim/neovim.git
synced 2025-09-12 22:38:16 +00:00
fix: anonymous sid not working
This commit is contained in:
@@ -1818,24 +1818,14 @@ void nlua_execute_on_key(int c)
|
||||
#endif
|
||||
}
|
||||
|
||||
// Checks if str is in blacklist array
|
||||
static bool is_in_ignorelist(const char *str, char *ignorelist[], int ignorelist_size)
|
||||
// Sets the editor "script context" during Lua execution. Used by :verbose.
|
||||
// @param[out] current
|
||||
void nlua_set_sctx(sctx_T *current)
|
||||
{
|
||||
for (int i = 0; i < ignorelist_size; i++) {
|
||||
if (strncmp(ignorelist[i], str, strlen(ignorelist[i])) == 0) {
|
||||
return true;
|
||||
}
|
||||
if (p_verbose <= 0 || current->sc_sid != SID_LUA) {
|
||||
return;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Get sctx of current file being sourced if doesn't exist generate it
|
||||
static sctx_T *nlua_get_sourcing_sctx(void)
|
||||
{
|
||||
lua_State *const lstate = global_lstate;
|
||||
sctx_T *retval = (sctx_T *)xmalloc(sizeof(sctx_T));
|
||||
retval->sc_seq = -1;
|
||||
retval->sc_sid = SID_LUA;
|
||||
retval->sc_lnum = -1;
|
||||
lua_Debug *info = (lua_Debug *)xmalloc(sizeof(lua_Debug));
|
||||
|
||||
// Files where internal wrappers are defined so we can ignore them
|
||||
@@ -1844,7 +1834,7 @@ static sctx_T *nlua_get_sourcing_sctx(void)
|
||||
"vim/_meta.lua",
|
||||
"vim/keymap.lua",
|
||||
};
|
||||
int blacklist_size = sizeof(ignorelist) / sizeof(ignorelist[0]);
|
||||
int ignorelist_size = sizeof(ignorelist) / sizeof(ignorelist[0]);
|
||||
|
||||
for (int level = 1; true; level++) {
|
||||
if (lua_getstack(lstate, level, info) != 1) {
|
||||
@@ -1854,31 +1844,30 @@ static sctx_T *nlua_get_sourcing_sctx(void)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (info->what[0] == 'C' || info->source[0] != '@'
|
||||
|| is_in_ignorelist(info->source+1, ignorelist, blacklist_size)) {
|
||||
bool is_ignored = false;
|
||||
if (info->what[0] == 'C' || info->source[0] != '@') {
|
||||
is_ignored = true;
|
||||
} else {
|
||||
for (int i = 0; i < ignorelist_size; i++) {
|
||||
if (strncmp(ignorelist[i], info->source+1, strlen(ignorelist[i])) == 0) {
|
||||
is_ignored = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_ignored) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
char *source_path = fix_fname(info->source + 1);
|
||||
get_current_script_id((char_u *)source_path, retval);
|
||||
get_current_script_id((char_u *)source_path, current);
|
||||
xfree(source_path);
|
||||
retval->sc_lnum = info->currentline;
|
||||
current->sc_lnum = info->currentline;
|
||||
current->sc_seq = -1;
|
||||
|
||||
cleanup:
|
||||
xfree(info);
|
||||
return retval;
|
||||
}
|
||||
|
||||
// Sets the editor "script context" during Lua execution. Used by :verbose.
|
||||
// @param[out] current
|
||||
void nlua_set_sctx(sctx_T *current)
|
||||
{
|
||||
if (p_verbose > 0 && current->sc_sid == SID_LUA) {
|
||||
sctx_T *lua_sctx = nlua_get_sourcing_sctx();
|
||||
*current = *lua_sctx;
|
||||
xfree(lua_sctx);
|
||||
}
|
||||
}
|
||||
|
||||
void nlua_do_ucmd(ucmd_T *cmd, exarg_T *eap)
|
||||
|
Reference in New Issue
Block a user