diff options
-rw-r--r-- | changelog.md | 1 | ||||
-rw-r--r-- | script/core/diagnostics/count-down-loop.lua | 13 | ||||
-rw-r--r-- | test/diagnostics/common.lua | 12 |
3 files changed, 21 insertions, 5 deletions
diff --git a/changelog.md b/changelog.md index 94b1f760..377489d4 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,7 @@ * `FIX` [#1354](https://github.com/sumneko/lua-language-server/issues/1354) * `FIX` [#1355](https://github.com/sumneko/lua-language-server/issues/1355) * `FIX` [#1363](https://github.com/sumneko/lua-language-server/issues/1363) +* `FIX` [#1365](https://github.com/sumneko/lua-language-server/issues/1365) * `FIX` [#1368](https://github.com/sumneko/lua-language-server/issues/1368) ## 3.5.0 diff --git a/script/core/diagnostics/count-down-loop.lua b/script/core/diagnostics/count-down-loop.lua index 9bc4b273..88cb06ab 100644 --- a/script/core/diagnostics/count-down-loop.lua +++ b/script/core/diagnostics/count-down-loop.lua @@ -10,12 +10,15 @@ return function (uri, callback) end guide.eachSourceType(state.ast, 'loop', function (source) - local maxNumer = source.max and tonumber(source.max[1]) - if maxNumer ~= 1 then + local maxNumber = source.max and tonumber(source.max[1]) + if not maxNumber then return end local minNumber = source.init and tonumber(source.init[1]) - if minNumber and minNumber <= 1 then + if minNumber and maxNumber and minNumber <= maxNumber then + return + end + if not minNumber and maxNumber > 1 then return end if not source.step then @@ -24,7 +27,7 @@ return function (uri, callback) finish = source.max.finish, message = lang.script('DIAG_COUNT_DOWN_LOOP' , ('%s, %s'):format(text:sub( - guide.positionToOffset(state, source.init.start), + guide.positionToOffset(state, source.init.start + 1), guide.positionToOffset(state, source.max.finish) ), '-1') ) @@ -37,7 +40,7 @@ return function (uri, callback) finish = source.step.finish, message = lang.script('DIAG_COUNT_DOWN_LOOP' , ('%s, -%s'):format(text:sub( - guide.positionToOffset(state, source.init.start), + guide.positionToOffset(state, source.init.start + 1), guide.positionToOffset(state, source.max.finish) ), source.step[1]) ) diff --git a/test/diagnostics/common.lua b/test/diagnostics/common.lua index 05656db5..9d337e53 100644 --- a/test/diagnostics/common.lua +++ b/test/diagnostics/common.lua @@ -1087,6 +1087,18 @@ end ]] TEST [[ +for i = <!100, 10, 1!> do + print(i) +end +]] + +TEST [[ +for i = <!1, -10!> do + print(i) +end +]] + +TEST [[ for i = 1, 1 do print(i) end |