Skip to content

Commit d30107b

Browse files
committed
fix run on save bug
1 parent a404336 commit d30107b

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

.vscode/on_editor_save.lua

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
--ANALYZE
22
require("nattlua.other.lua_compat")
3+
_G.REUSE_BASE_ENV = true
34
local path = ...--[[# as string | nil]]
45
assert(type(path) == "string", "expected path string")
56
local is_lua = path:sub(-4) == ".lua"
@@ -36,6 +37,26 @@ then
3637
return
3738
end
3839

40+
if not _G.ROOT_PATH then
41+
local source = debug.getinfo(1, "S").source:sub(2)
42+
local start = source:find("%.vscode/on_editor_save%.lua$")
43+
44+
if start then
45+
local root = source:sub(1, start - 1)
46+
47+
if root == "" then
48+
_G.ROOT_PATH = "./"
49+
else
50+
if root:sub(-1) ~= "/" then root = root .. "/" end
51+
52+
_G.ROOT_PATH = root
53+
end
54+
else
55+
_G.ROOT_PATH = "./"
56+
end
57+
end
58+
59+
_G.REUSE_BASE_ENV = true
3960
_G.HOTRELOAD = true
4061
_G.path = path
4162
_G.code = code

0 commit comments

Comments
 (0)