From 0e687b98624860a169b4a58813e6e4c38e3783af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 8 Jun 2022 00:04:07 +0800 Subject: cleanup --- script/parser/guide.lua | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'script/parser/guide.lua') 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 -- cgit v1.2.3