A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/neovim/neovim/commit/7b6ee3ef0a2d64657c8ca25f440e010c6dc75408 below:

anonymous sid not working · neovim/neovim@7b6ee3e · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+59

-34

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+59

-34

lines changed Original file line number Diff line number Diff line change

@@ -9369,10 +9369,31 @@ static hashtab_T *find_var_ht_dict(const char *name, const size_t name_len, cons

9369 9369

} else if (*name == 'l' && funccal != NULL) { // local variable

9370 9370

*d = &funccal->l_vars;

9371 9371

} else if (*name == 's' // script variable

9372 -

&& (current_sctx.sc_sid > 0 || current_sctx.sc_sid == SID_STR)

9372 +

&& (current_sctx.sc_sid > 0 || current_sctx.sc_sid == SID_STR

9373 +

|| current_sctx.sc_sid == SID_LUA)

9373 9374

&& current_sctx.sc_sid <= ga_scripts.ga_len) {

9374 9375

// For anonymous scripts without a script item, create one now so script vars can be used

9375 -

if (current_sctx.sc_sid == SID_STR) {

9376 +

if (current_sctx.sc_sid == SID_LUA) {

9377 +

// try to resolve lua filename & line no so it can be shown in lastset messages.

9378 +

nlua_set_sctx(&current_sctx);

9379 +

if (current_sctx.sc_sid != SID_LUA) {

9380 +

// Great we have valid location. Now here this out we'll create a new

9381 +

// script context with the name and lineno of this one. why ?

9382 +

// for behavioral consistency. With this different anonymous exec from

9383 +

// same file can't access each others script local stuff. We need to do

9384 +

// this all other cases except this will act like that otherwise.

9385 +

const LastSet last_set = (LastSet){

9386 +

.script_ctx = current_sctx,

9387 +

.channel_id = LUA_INTERNAL_CALL,

9388 +

};

9389 +

bool should_free;

9390 +

// should_free is ignored as script_sctx will be resolved to a fnmae

9391 +

// & new_script_item will consume it.

9392 +

char_u *sc_name = get_scriptname(last_set, &should_free);

9393 +

new_script_item(sc_name, &current_sctx.sc_sid);

9394 +

}

9395 +

}

9396 +

if (current_sctx.sc_sid == SID_STR || current_sctx.sc_sid == SID_LUA) {

9376 9397

new_script_item(NULL, &current_sctx.sc_sid);

9377 9398

}

9378 9399

*d = &SCRIPT_SV(current_sctx.sc_sid)->sv_dict;

Original file line number Diff line number Diff line change

@@ -1818,24 +1818,14 @@ void nlua_execute_on_key(int c)

1818 1818

#endif

1819 1819

}

1820 1820 1821 -

// Checks if str is in blacklist array

1822 -

static bool is_in_ignorelist(const char *str, char *ignorelist[], int ignorelist_size)

1821 +

// Sets the editor "script context" during Lua execution. Used by :verbose.

1822 +

// @param[out] current

1823 +

void nlua_set_sctx(sctx_T *current)

1823 1824

{

1824 -

for (int i = 0; i < ignorelist_size; i++) {

1825 -

if (strncmp(ignorelist[i], str, strlen(ignorelist[i])) == 0) {

1826 -

return true;

1827 -

}

1825 +

if (p_verbose <= 0 || current->sc_sid != SID_LUA) {

1826 +

return;

1828 1827

}

1829 -

return false;

1830 -

}

1831 -

// Get sctx of current file being sourced if doesn't exist generate it

1832 -

static sctx_T *nlua_get_sourcing_sctx(void)

1833 -

{

1834 1828

lua_State *const lstate = global_lstate;

1835 -

sctx_T *retval = (sctx_T *)xmalloc(sizeof(sctx_T));

1836 -

retval->sc_seq = -1;

1837 -

retval->sc_sid = SID_LUA;

1838 -

retval->sc_lnum = -1;

1839 1829

lua_Debug *info = (lua_Debug *)xmalloc(sizeof(lua_Debug));

1840 1830 1841 1831

// Files where internal wrappers are defined so we can ignore them

@@ -1844,7 +1834,7 @@ static sctx_T *nlua_get_sourcing_sctx(void)

1844 1834

"vim/_meta.lua",

1845 1835

"vim/keymap.lua",

1846 1836

};

1847 -

int blacklist_size = sizeof(ignorelist) / sizeof(ignorelist[0]);

1837 +

int ignorelist_size = sizeof(ignorelist) / sizeof(ignorelist[0]);

1848 1838 1849 1839

for (int level = 1; true; level++) {

1850 1840

if (lua_getstack(lstate, level, info) != 1) {

@@ -1854,31 +1844,30 @@ static sctx_T *nlua_get_sourcing_sctx(void)

1854 1844

goto cleanup;

1855 1845

}

1856 1846 1857 -

if (info->what[0] == 'C' || info->source[0] != '@'

1858 -

|| is_in_ignorelist(info->source+1, ignorelist, blacklist_size)) {

1847 +

bool is_ignored = false;

1848 +

if (info->what[0] == 'C' || info->source[0] != '@') {

1849 +

is_ignored = true;

1850 +

} else {

1851 +

for (int i = 0; i < ignorelist_size; i++) {

1852 +

if (strncmp(ignorelist[i], info->source+1, strlen(ignorelist[i])) == 0) {

1853 +

is_ignored = true;

1854 +

break;

1855 +

}

1856 +

}

1857 +

}

1858 +

if (is_ignored) {

1859 1859

continue;

1860 1860

}

1861 1861

break;

1862 1862

}

1863 1863

char *source_path = fix_fname(info->source + 1);

1864 -

get_current_script_id((char_u *)source_path, retval);

1864 +

get_current_script_id((char_u *)source_path, current);

1865 1865

xfree(source_path);

1866 -

retval->sc_lnum = info->currentline;

1866 +

current->sc_lnum = info->currentline;

1867 +

current->sc_seq = -1;

1867 1868 1868 1869

cleanup:

1869 1870

xfree(info);

1870 -

return retval;

1871 -

}

1872 - 1873 -

// Sets the editor "script context" during Lua execution. Used by :verbose.

1874 -

// @param[out] current

1875 -

void nlua_set_sctx(sctx_T *current)

1876 -

{

1877 -

if (p_verbose > 0 && current->sc_sid == SID_LUA) {

1878 -

sctx_T *lua_sctx = nlua_get_sourcing_sctx();

1879 -

*current = *lua_sctx;

1880 -

xfree(lua_sctx);

1881 -

}

1882 1871

}

1883 1872 1884 1873

void nlua_do_ucmd(ucmd_T *cmd, exarg_T *eap)

Original file line number Diff line number Diff line change

@@ -38,6 +38,13 @@ function Close_Window() abort\

38 38

wincmd -\

39 39

endfunction\

40 40

", false)

41 + 42 +

local ret = vim.api.nvim_exec ("\

43 +

function! s:return80()\

44 +

return 80\

45 +

endfunction\

46 +

let &tw = s:return80()\

47 +

", true)

41 48

]])

42 49

exec(':source '..script_file)

43 50

end)

@@ -125,6 +132,14 @@ test_group FileType

125 132

endfunction]],

126 133

script_location), result)

127 134

end)

135 + 136 +

it('"Last set" works with anonymous sid', function()

137 +

local result = exec_capture(':verbose set tw?')

138 +

eq(string.format([[

139 +

textwidth=80

140 +

Last set from %s line 22]],

141 +

script_location), result)

142 +

end)

128 143

end)

129 144 130 145

describe('lua verbose:', function()

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4