summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-01-05 09:14:45 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-01-05 09:14:45 +0800
commite022ec0124382af1fb1dfa05ceba1e18989f5dc5 (patch)
treebfae153f50f53ecc23650d5af06ea527433ca5f3
parent3b75dfcc13e84bf10499847604f705d73fb27cef (diff)
downloadlua-language-server-e022ec0124382af1fb1dfa05ceba1e18989f5dc5.zip
fix
-rw-r--r--script/core/diagnostics/count-down-loop.lua4
-rw-r--r--test/diagnostics/init.lua6
2 files changed, 10 insertions, 0 deletions
diff --git a/script/core/diagnostics/count-down-loop.lua b/script/core/diagnostics/count-down-loop.lua
index b64391fd..8cd26dcd 100644
--- a/script/core/diagnostics/count-down-loop.lua
+++ b/script/core/diagnostics/count-down-loop.lua
@@ -17,6 +17,10 @@ return function (uri, callback)
if maxNumer ~= 1 then
return
end
+ local minNumber = source.loc and source.loc.value and source.loc.value.type == 'number' and tonumber(source.loc.value[1])
+ if minNumber and minNumber <= 1 then
+ return
+ end
if not source.step then
callback {
start = source.loc.value.start,
diff --git a/test/diagnostics/init.lua b/test/diagnostics/init.lua
index 8a89179f..8a8343cc 100644
--- a/test/diagnostics/init.lua
+++ b/test/diagnostics/init.lua
@@ -993,3 +993,9 @@ for i = <!10, 1, 5!> do
print(i)
end
]]
+
+TEST [[
+for i = 1, 1 do
+ print(i)
+end
+]]