diff options
author | 2018-09-10 14:19:19 -0400 | |
---|---|---|
committer | 2018-09-10 14:19:19 -0400 | |
commit | 638130774ecbd81a8438adb61385208f584659ae (patch) | |
tree | f58bab99129f23b8667c542e1703dd7938329080 /src | |
parent | 8f1b55bfb7dfe2272d489dc70c745e6125662a0c (diff) | |
download | textadept-638130774ecbd81a8438adb61385208f584659ae.tar.gz textadept-638130774ecbd81a8438adb61385208f584659ae.zip |
Added ability to save/restore persistent data during reset.
Diffstat (limited to 'src')
-rw-r--r-- | src/textadept.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/textadept.c b/src/textadept.c index afbb7ee7..f40ab00f 100644 --- a/src/textadept.c +++ b/src/textadept.c @@ -1395,14 +1395,16 @@ static int lL_dofile(lua_State *L, const char *filename) { /** `_G.reset()` Lua function. */ static int lreset(lua_State *L) { - lL_event(L, "reset_before", -1); + int persist_ref = (lua_newtable(L), luaL_ref(L, LUA_REGISTRYINDEX)); + lua_rawgeti(L, LUA_REGISTRYINDEX, persist_ref); // lL_event will unref + lL_event(L, "reset_before", LUA_TTABLE, luaL_ref(L, LUA_REGISTRYINDEX), -1); lL_init(L, 0, NULL, TRUE); l_setglobalview(L, focused_view); l_setglobaldoc(L, SS(focused_view, SCI_GETDOCPOINTER, 0, 0)); lua_pushnil(L), lua_setglobal(L, "arg"); lL_dofile(L, "init.lua"), lL_event(L, "initialized", -1); lua_getfield(L, LUA_REGISTRYINDEX, "ta_arg"), lua_setglobal(L, "arg"); - lL_event(L, "reset_after", -1); + lL_event(L, "reset_after", LUA_TTABLE, persist_ref, -1); return 0; } |