Skip to content

Commit

Permalink
fix #625
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko committed Aug 5, 2021
1 parent 9e01f8d commit ee1fd6e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
16 changes: 11 additions & 5 deletions script/core/searcher.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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]
Expand Down
10 changes: 10 additions & 0 deletions test/type_inference/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
]]

0 comments on commit ee1fd6e

Please sign in to comment.