Skip to content

Commit 366d163

Browse files
committed
fix #567
1 parent 1e7e9eb commit 366d163

File tree

7 files changed

+41
-7
lines changed

7 files changed

+41
-7
lines changed

changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# changelog
22

33
## 2.0.2
4+
* `FIX` [#567](https://github.com./sumneko/lua-language-server/issues/567)
45
* `FIX` [#570](https://github.com./sumneko/lua-language-server/issues/570)
56

67
## 2.0.1

script/core/noder.lua

+11
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,17 @@ function m.getLastID(id)
988988
return lastID
989989
end
990990

991+
---获取ID的长度
992+
---@param id string
993+
---@return integer
994+
function m.getIDLength(id)
995+
if not id then
996+
return 0
997+
end
998+
local _, count = id:gsub(SPLIT_CHAR, SPLIT_CHAR)
999+
return count + 1
1000+
end
1001+
9911002
---测试id是否包含field,如果遇到函数调用则中断
9921003
---@param id string
9931004
---@return boolean

script/core/searcher.lua

+8-5
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@ function m.searchRefsByID(status, uri, expect, mode)
249249

250250
local callStack = status.callStack
251251

252-
local mark = {}
252+
local mark = status.flock[uri] or {}
253+
status.flock[uri] = mark
253254

254255
local function search(id, field)
255256
local firstID = noder.getFirstID(id)
@@ -297,7 +298,8 @@ function m.searchRefsByID(status, uri, expect, mode)
297298
cmark = {}
298299
mark[id] = cmark
299300
end
300-
if cmark[LAST] then
301+
local fieldLength = noder.getIDLength(field)
302+
if cmark[LAST] and fieldLength >= cmark[LAST] then
301303
return
302304
end
303305
local lastID = noder.getLastID(id)
@@ -308,7 +310,7 @@ function m.searchRefsByID(status, uri, expect, mode)
308310
if field then
309311
newField = newField .. field
310312
end
311-
cmark[LAST] = true
313+
cmark[LAST] = fieldLength
312314
search(lastID, newField)
313315
return lastID
314316
end
@@ -620,10 +622,10 @@ function m.searchRefsByID(status, uri, expect, mode)
620622

621623
local stepCount = 0
622624
local stepMaxCount = 1e3
623-
local statusMaxCount = 1e4
625+
local statusMaxCount = 1e5
624626
if mode == 'allref' or mode == 'alldef' then
625627
stepMaxCount = 1e4
626-
statusMaxCount = 1e5
628+
statusMaxCount = 1e6
627629
end
628630
function searchStep(id, field)
629631
stepCount = stepCount + 1
@@ -853,6 +855,7 @@ function m.status(mode)
853855
callStack = {},
854856
crossed = {},
855857
lock = {},
858+
flock = {},
856859
results = {},
857860
rmark = {},
858861
smark = {},

test.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ local fs = require 'bee.filesystem'
99
ROOT = fs.path(rootPath)
1010
TEST = true
1111
DEVELOP = true
12-
--FOOTPRINT = true
12+
FOOTPRINT = true
1313
--TRACE = true
1414
LOGPATH = LOGPATH or (ROOT .. '/log')
1515
METAPATH = METAPATH or (ROOT .. '/meta')

test/crossfile/definition.lua

+15
Original file line numberDiff line numberDiff line change
@@ -771,3 +771,18 @@ TEST {
771771
},
772772
}
773773
config.config.runtime.path = originRuntimePath
774+
775+
TEST {
776+
{
777+
path = 'a.lua',
778+
content = [[
779+
a = b.x
780+
]],
781+
},
782+
{
783+
path = 'b.lua',
784+
content = [[
785+
b = a.<?x?>
786+
]],
787+
},
788+
}

test/full/projects.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ local function doProjects(pathname)
2525
local uri = furi.encode(path:string())
2626
local text = fsu.loadFile(path)
2727
files.setText(uri, text)
28-
--files.open(uri)
28+
files.open(uri)
2929
end)
3030

3131
print('开始诊断...')

test/type_inference/init.lua

+4
Original file line numberDiff line numberDiff line change
@@ -742,3 +742,7 @@ local <?test?> = Rct.new(Rct)
742742
743743
return test
744744
]]
745+
746+
TEST 'function' [[
747+
string.gsub():gsub():<?gsub?>()
748+
]]

0 commit comments

Comments
 (0)