From 6a88abae3d8ceb4463da423e934cc03e6e5ce5fa Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Sat, 8 Jun 2024 14:39:58 +0200 Subject: Lua: keep CommonState object in the registry The state is an internal value and should be treated as such. The `PANDOC_STATE` global is merely a copy; unsetting the global no longer breaks the Lua engine. --- pandoc-lua-engine/src/Text/Pandoc/Lua/PandocLua.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'pandoc-lua-engine/src') diff --git a/pandoc-lua-engine/src/Text/Pandoc/Lua/PandocLua.hs b/pandoc-lua-engine/src/Text/Pandoc/Lua/PandocLua.hs index 5062672e9..9c4bebdd2 100644 --- a/pandoc-lua-engine/src/Text/Pandoc/Lua/PandocLua.hs +++ b/pandoc-lua-engine/src/Text/Pandoc/Lua/PandocLua.hs @@ -77,10 +77,12 @@ instance PandocMonad PandocLua where getModificationTime = IO.getModificationTime getCommonState = PandocLua $ do - Lua.getglobal "PANDOC_STATE" + Lua.getfield registryindex "PANDOC_STATE" forcePeek $ peekCommonState Lua.top `lastly` pop 1 putCommonState cst = PandocLua $ do pushCommonState cst + Lua.pushvalue Lua.top + Lua.setfield registryindex "PANDOC_STATE" Lua.setglobal "PANDOC_STATE" logOutput = IO.logOutput -- cgit v1.2.3