summaryrefslogtreecommitdiff
path: root/script/core/diagnostics/count-down-loop.lua
diff options
context:
space:
mode:
authorArcanox <arcanox@arcanox.me>2021-09-25 18:00:15 -0500
committerArcanox <arcanox@arcanox.me>2021-09-25 18:00:15 -0500
commitdc685d1addad2f2e57f55a20bb6cca79c222c130 (patch)
treeabb200fd7f217460a4543cb6f32af7ebac308bc0 /script/core/diagnostics/count-down-loop.lua
parenta465b35d5eefc11c1daf3c29b41ce95ee098a782 (diff)
parent1f0a2d0e9283a4cb7f7b3fc72258eb1c5ba4e5dd (diff)
downloadlua-language-server-dc685d1addad2f2e57f55a20bb6cca79c222c130.zip
Merge branch 'master' into improve-semantic-highlighting
# Conflicts: # script/core/semantic-tokens.lua
Diffstat (limited to 'script/core/diagnostics/count-down-loop.lua')
-rw-r--r--script/core/diagnostics/count-down-loop.lua25
1 files changed, 17 insertions, 8 deletions
diff --git a/script/core/diagnostics/count-down-loop.lua b/script/core/diagnostics/count-down-loop.lua
index 1a7dcf7d..49c48880 100644
--- a/script/core/diagnostics/count-down-loop.lua
+++ b/script/core/diagnostics/count-down-loop.lua
@@ -10,30 +10,39 @@ return function (uri, callback)
end
guide.eachSourceType(state.ast, 'loop', function (source)
- if not source.loc or not source.loc.value then
- return
- end
local maxNumer = source.max and tonumber(source.max[1])
if maxNumer ~= 1 then
return
end
- local minNumber = source.loc and source.loc.value and tonumber(source.loc.value[1])
+ local minNumber = source.init and tonumber(source.init[1])
if minNumber and minNumber <= 1 then
return
end
if not source.step then
callback {
- start = source.loc.value.start,
+ start = source.init.start,
finish = source.max.finish,
- message = lang.script('DIAG_COUNT_DOWN_LOOP', ('%s, %s'):format(text:sub(source.loc.value.start, source.max.finish), '-1'))
+ message = lang.script('DIAG_COUNT_DOWN_LOOP'
+ , ('%s, %s'):format(text:sub(
+ guide.positionToOffset(state, source.init.start),
+ guide.positionToOffset(state, source.max.finish)
+ )
+ , '-1')
+ )
}
else
local stepNumber = tonumber(source.step[1])
if stepNumber and stepNumber > 0 then
callback {
- start = source.loc.value.start,
+ start = source.init.start,
finish = source.step.finish,
- message = lang.script('DIAG_COUNT_DOWN_LOOP', ('%s, -%s'):format(text:sub(source.loc.value.start, source.max.finish), source.step[1]))
+ message = lang.script('DIAG_COUNT_DOWN_LOOP'
+ , ('%s, -%s'):format(text:sub(
+ guide.positionToOffset(state, source.init.start),
+ guide.positionToOffset(state, source.max.finish)
+ )
+ , source.step[1])
+ )
}
end
end