summaryrefslogtreecommitdiff
path: root/script/parser/guide.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-06-08 00:04:07 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-06-08 00:04:07 +0800
commit0e687b98624860a169b4a58813e6e4c38e3783af (patch)
tree78c22234459179feda17e2ae272f848aac45faa0 /script/parser/guide.lua
parent735210cb6ba3e4e0689efc3155319b0f195eac8d (diff)
downloadlua-language-server-0e687b98624860a169b4a58813e6e4c38e3783af.zip
cleanup
Diffstat (limited to 'script/parser/guide.lua')
-rw-r--r--script/parser/guide.lua14
1 files changed, 11 insertions, 3 deletions
diff --git a/script/parser/guide.lua b/script/parser/guide.lua
index b22001fc..2bd9066b 100644
--- a/script/parser/guide.lua
+++ b/script/parser/guide.lua
@@ -468,19 +468,27 @@ end
function m.getLocal(source, name, pos)
local block = source
-- find nearest source
- while block.start > pos or block.finish < pos do
- block = block.parent
+ for _ = 1, 10000 do
if not block then
return nil
end
+ if block.start <= pos and block.finish >= pos then
+ break
+ end
+ block = block.parent
end
+
m.eachSourceContain(block, pos, function (src)
if blockTypes[src.type]
and (src.finish - src.start) < (block.finish - src.start) then
block = src
end
end)
- while block do
+
+ for _ = 1, 10000 do
+ if not block then
+ break
+ end
local res
if block.locals then
for _, loc in ipairs(block.locals) do