Skip to content

Commit 0e687b9

Browse files
committed
cleanup
1 parent 735210c commit 0e687b9

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

script/parser/guide.lua

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,19 +468,27 @@ end
468468
function m.getLocal(source, name, pos)
469469
local block = source
470470
-- find nearest source
471-
while block.start > pos or block.finish < pos do
472-
block = block.parent
471+
for _ = 1, 10000 do
473472
if not block then
474473
return nil
475474
end
475+
if block.start <= pos and block.finish >= pos then
476+
break
477+
end
478+
block = block.parent
476479
end
480+
477481
m.eachSourceContain(block, pos, function (src)
478482
if blockTypes[src.type]
479483
and (src.finish - src.start) < (block.finish - src.start) then
480484
block = src
481485
end
482486
end)
483-
while block do
487+
488+
for _ = 1, 10000 do
489+
if not block then
490+
break
491+
end
484492
local res
485493
if block.locals then
486494
for _, loc in ipairs(block.locals) do

0 commit comments

Comments
 (0)