summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-08-05 21:32:20 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-08-05 21:32:20 +0800
commitee1fd6ecca105f554ac8f7888e4f951c47f9e967 (patch)
treedc2c0330a0a4e46ca0e347102ba59f7e427fe132
parent9e01f8d8eb7a408b45fce7a6231c690fede87da0 (diff)
downloadlua-language-server-ee1fd6ecca105f554ac8f7888e4f951c47f9e967.zip
fix #625
-rw-r--r--changelog.md1
-rw-r--r--script/core/searcher.lua16
-rw-r--r--test/type_inference/init.lua10
3 files changed, 22 insertions, 5 deletions
diff --git a/changelog.md b/changelog.md
index 3634d07d..b26bbc1a 100644
--- a/changelog.md
+++ b/changelog.md
@@ -2,6 +2,7 @@
## 2.4.0
* `CHG` improve performance
+* `FIX` [#625](https://github.com/sumneko/lua-language-server/issues/625)
## 2.3.3
`2021-7-26`
diff --git a/script/core/searcher.lua b/script/core/searcher.lua
index 10571c03..066fb507 100644
--- a/script/core/searcher.lua
+++ b/script/core/searcher.lua
@@ -364,13 +364,16 @@ function m.searchRefsByID(status, suri, expect, mode)
local brejectMap = setmetatable({}, uriMapMT)
local slockMap = setmetatable({}, uriMapMT)
local elockMap = setmetatable({}, uriMapMT)
+ local ecallMap = setmetatable({}, uriMapMT)
- local function lockExpanding(elock, id, field)
+ local function lockExpanding(elock, ecall, id, field)
if not field then
field = ''
end
+ local call = callStack[#callStack]
local locked = elock[id]
- if locked and field then
+ local called = ecall[id]
+ if locked and called == call then
if #locked <= #field then
if ssub(field, -#locked) == locked then
footprint(status, 'elocked:', id, locked, field)
@@ -379,11 +382,13 @@ function m.searchRefsByID(status, suri, expect, mode)
end
end
elock[id] = field
+ ecall[id] = call
return true
end
- local function releaseExpanding(elock, id, field)
+ local function releaseExpanding(elock, ecall, id, field)
elock[id] = nil
+ ecall[id] = nil
end
local function search(uri, id, field)
@@ -812,15 +817,16 @@ function m.searchRefsByID(status, suri, expect, mode)
end
local elock = global and elockMap['@global'] or elockMap[uri]
+ local ecall = global and ecallMap['@global'] or ecallMap[uri]
- if lockExpanding(elock, id, field) then
+ if lockExpanding(elock, ecall, id, field) then
if noders.forward[id] then
checkForward(uri, id, field)
end
if noders.backward[id] then
checkBackward(uri, id, field)
end
- releaseExpanding(elock, id, field)
+ releaseExpanding(elock, ecall, id, field)
end
local source = noders.source[id]
diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua
index a3a06bfd..a20a96e9 100644
--- a/test/type_inference/init.lua
+++ b/test/type_inference/init.lua
@@ -901,3 +901,13 @@ local t
local <?v?> = t[1]
]]
+
+TEST 'string' [[
+---@type string[][]
+local v = {}
+
+for _, a in ipairs(v) do
+ for i, <?b?> in ipairs(a) do
+ end
+end
+]]