Skip to content

Commit ee1fd6e

Browse files
committed
fix #625
1 parent 9e01f8d commit ee1fd6e

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## 2.4.0
44
* `CHG` improve performance
5+
* `FIX` [#625](https://github.com/sumneko/lua-language-server/issues/625)
56

67
## 2.3.3
78
`2021-7-26`

script/core/searcher.lua

+11-5
Original file line numberDiff line numberDiff line change
@@ -364,13 +364,16 @@ function m.searchRefsByID(status, suri, expect, mode)
364364
local brejectMap = setmetatable({}, uriMapMT)
365365
local slockMap = setmetatable({}, uriMapMT)
366366
local elockMap = setmetatable({}, uriMapMT)
367+
local ecallMap = setmetatable({}, uriMapMT)
367368

368-
local function lockExpanding(elock, id, field)
369+
local function lockExpanding(elock, ecall, id, field)
369370
if not field then
370371
field = ''
371372
end
373+
local call = callStack[#callStack]
372374
local locked = elock[id]
373-
if locked and field then
375+
local called = ecall[id]
376+
if locked and called == call then
374377
if #locked <= #field then
375378
if ssub(field, -#locked) == locked then
376379
footprint(status, 'elocked:', id, locked, field)
@@ -379,11 +382,13 @@ function m.searchRefsByID(status, suri, expect, mode)
379382
end
380383
end
381384
elock[id] = field
385+
ecall[id] = call
382386
return true
383387
end
384388

385-
local function releaseExpanding(elock, id, field)
389+
local function releaseExpanding(elock, ecall, id, field)
386390
elock[id] = nil
391+
ecall[id] = nil
387392
end
388393

389394
local function search(uri, id, field)
@@ -812,15 +817,16 @@ function m.searchRefsByID(status, suri, expect, mode)
812817
end
813818

814819
local elock = global and elockMap['@global'] or elockMap[uri]
820+
local ecall = global and ecallMap['@global'] or ecallMap[uri]
815821

816-
if lockExpanding(elock, id, field) then
822+
if lockExpanding(elock, ecall, id, field) then
817823
if noders.forward[id] then
818824
checkForward(uri, id, field)
819825
end
820826
if noders.backward[id] then
821827
checkBackward(uri, id, field)
822828
end
823-
releaseExpanding(elock, id, field)
829+
releaseExpanding(elock, ecall, id, field)
824830
end
825831

826832
local source = noders.source[id]

test/type_inference/init.lua

+10
Original file line numberDiff line numberDiff line change
@@ -901,3 +901,13 @@ local t
901901
902902
local <?v?> = t[1]
903903
]]
904+
905+
TEST 'string' [[
906+
---@type string[][]
907+
local v = {}
908+
909+
for _, a in ipairs(v) do
910+
for i, <?b?> in ipairs(a) do
911+
end
912+
end
913+
]]

0 commit comments

Comments
 (0)