diff options
author | CppCXY <812125110@qq.com> | 2022-08-11 19:36:36 +0800 |
---|---|---|
committer | CppCXY <812125110@qq.com> | 2022-08-11 19:36:36 +0800 |
commit | ff9103ae4001d8e520171b99cd192997fc689bc9 (patch) | |
tree | 04c0b685e81aac48210604dc12d24b91862a36d9 /script/core/diagnostics/count-down-loop.lua | |
parent | 40f191a85ea21bb64c427f9dab4bc597e2a0ea1b (diff) | |
parent | 82bcfef9037c26681993c94b2f92b68d335de3c6 (diff) | |
download | lua-language-server-ff9103ae4001d8e520171b99cd192997fc689bc9.zip |
Merge branch 'master' of github.com:CppCXY/lua-language-server
Diffstat (limited to 'script/core/diagnostics/count-down-loop.lua')
-rw-r--r-- | script/core/diagnostics/count-down-loop.lua | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/script/core/diagnostics/count-down-loop.lua b/script/core/diagnostics/count-down-loop.lua index 9bc4b273..bd6e5ee3 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]) ) |