diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-21 17:50:23 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-21 17:50:23 +0800 |
commit | a143a0f6f6f977e2db92fd1fe45e1b6f9dc933d1 (patch) | |
tree | 489ae3d8c97c3503d6a278b1c28a9bda1f126fd3 /server/src/matcher/find_result.lua | |
parent | 11cf0b1af0706a3fc94a1c303272ec3ba3344af7 (diff) | |
download | lua-language-server-a143a0f6f6f977e2db92fd1fe45e1b6f9dc933d1.zip |
整理代码
Diffstat (limited to 'server/src/matcher/find_result.lua')
-rw-r--r-- | server/src/matcher/find_result.lua | 58 |
1 files changed, 2 insertions, 56 deletions
diff --git a/server/src/matcher/find_result.lua b/server/src/matcher/find_result.lua index dcf00c66..940ef80c 100644 --- a/server/src/matcher/find_result.lua +++ b/server/src/matcher/find_result.lua @@ -38,60 +38,6 @@ local function findAtPos(results, pos) return res[1].object, res[1].source end -local function findClosePos(results, pos) - local curDis = math.maxinteger - local parent = nil - for sources, object in pairs(results.sources) do - if sources.type == 'multi-source' then - for _, source in ipairs(sources) do - if source.type ~= 'simple' then - local dis = pos - source.finish - if dis > 0 and dis < curDis then - curDis = dis - parent = object - end - end - end - else - local source = sources - if source.type ~= 'simple' then - local dis = pos - source.finish - if dis > 0 and dis < curDis then - curDis = dis - parent = object - end - end - end - end - if parent then - -- 造个假的 DirtyName - local source = { - type = 'name', - start = pos, - finish = pos, - [1] = '', - } - local result = { - type = 'field', - parent = parent, - key = '', - source = source, - } - return result, source - end - return nil -end - -return function (vm, pos, close) - local results = vm.results - if close then - local obj, source = findAtPos(results, pos) - if obj then - return obj, source - else - return findClosePos(results, pos) - end - else - return findAtPos(results, pos) - end +return function (vm, pos) + return findAtPos(vm.results, pos) end |