diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-27 16:50:49 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-27 16:50:49 +0800 |
commit | d19d957a4a141c854f3acb3f4292dfdb5b79e137 (patch) | |
tree | 38f874683055e361b83ab11bfb3369a8eed6b82d /server/src/matcher/find_result.lua | |
parent | 5a1a7eba965aa447d32f2c3be054bcbbdca0388b (diff) | |
download | lua-language-server-d19d957a4a141c854f3acb3f4292dfdb5b79e137.zip |
整理代码
Diffstat (limited to 'server/src/matcher/find_result.lua')
-rw-r--r-- | server/src/matcher/find_result.lua | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/server/src/matcher/find_result.lua b/server/src/matcher/find_result.lua index 940ef80c..ac8dc3f4 100644 --- a/server/src/matcher/find_result.lua +++ b/server/src/matcher/find_result.lua @@ -5,7 +5,7 @@ local function isContainPos(obj, pos) return false end -local function findAtPos(results, pos) +local function findAtPos(results, pos, level) local res = {} for sources, object in pairs(results.sources) do if sources.type == 'multi-source' then @@ -35,9 +35,13 @@ local function findAtPos(results, pos) table.sort(res, function (a, b) return a.range < b.range end) - return res[1].object, res[1].source + local data = res[level or 1] + if not data then + return nil + end + return data.object, data.source end -return function (vm, pos) - return findAtPos(vm.results, pos) +return function (vm, pos, level) + return findAtPos(vm.results, pos, level) end |