summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTyler Miller <tmillr@proton.me>2024-08-11 00:54:00 -0700
committer最萌小汐 <sumneko@hotmail.com>2024-08-15 14:43:03 +0800
commitc51f0389096e12a02711b911b7272f49910b1f1b (patch)
tree8edf8f469738e920c5b61e1b4541315b21db5be8
parentd6d3d4b96b249310552ef6081dc35a401a219239 (diff)
downloadlua-language-server-c51f0389096e12a02711b911b7272f49910b1f1b.zip
fix(hint): attempt to index a nil value
Fixes: #2788
-rw-r--r--changelog.md1
-rw-r--r--script/core/hint.lua3
2 files changed, 4 insertions, 0 deletions
diff --git a/changelog.md b/changelog.md
index 096b644a..070f0b8f 100644
--- a/changelog.md
+++ b/changelog.md
@@ -2,6 +2,7 @@
## Unreleased
<!-- Add all new changes here. They will be moved under a version at release -->
+* `FIX` Error `attempt to index a nil value` when `Lua.hint.semicolon == 'All'` [#2788](https://github.com/LuaLS/lua-language-server/issues/2788)
## 3.10.3
`2024-8-8`
diff --git a/script/core/hint.lua b/script/core/hint.lua
index 9d098aa9..b0ff5aa7 100644
--- a/script/core/hint.lua
+++ b/script/core/hint.lua
@@ -287,6 +287,8 @@ local function semicolonHint(uri, results, start, finish)
---@async
guide.eachSourceTypes(state.ast, blockTypes, function (src)
await.delay()
+ if #src < 1 then return end
+
for i = 1, #src - 1 do
local current = src[i]
local next = src[i+1]
@@ -313,6 +315,7 @@ local function semicolonHint(uri, results, start, finish)
end
end
end
+
if mode == 'All' then
local last = src[#src]
results[#results+1] = {