summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/src/core/find_source.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/server/src/core/find_source.lua b/server/src/core/find_source.lua
index 65df6b95..4c4c460c 100644
--- a/server/src/core/find_source.lua
+++ b/server/src/core/find_source.lua
@@ -20,8 +20,19 @@ local function findAtPos(sources, pos, level)
return nil
end
table.sort(res, function (a, b)
+ if a == b then
+ return false
+ end
local rangeA = a.finish - a.start
local rangeB = b.finish - b.start
+ -- 特殊处理:func 'str' 的情况下,list与string的范围会完全相同,此时取string
+ if rangeA == rangeB then
+ if b.type == 'call' and #b == 1 and b[1] == a then
+ return true
+ else
+ return false
+ end
+ end
return rangeA < rangeB
end)
local source = res[level or 1]