From ee1fd6ecca105f554ac8f7888e4f951c47f9e967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 5 Aug 2021 21:32:20 +0800 Subject: [PATCH] fix #625 --- changelog.md | 1 + script/core/searcher.lua | 16 +++++++++++----- test/type_inference/init.lua | 10 ++++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/changelog.md b/changelog.md index 3634d07df..b26bbc1a2 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 10571c03b..066fb5075 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 a3a06bfdf..a20a96e95 100644 --- a/test/type_inference/init.lua +++ b/test/type_inference/init.lua @@ -901,3 +901,13 @@ local t local = t[1] ]] + +TEST 'string' [[ +---@type string[][] +local v = {} + +for _, a in ipairs(v) do + for i, in ipairs(a) do + end +end +]]