diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-26 14:12:57 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-26 14:12:57 +0800 |
commit | 86a9b83d68da99f26a56ce914c65698a3714f0da (patch) | |
tree | c6a4fc06f27f13d0200e15f54d443952901921b2 | |
parent | 72382639d52d66de5807157fea232646d27f9554 (diff) | |
download | lua-language-server-86a9b83d68da99f26a56ce914c65698a3714f0da.zip |
跨文件转到时,只找最后一个定义
-rw-r--r-- | server/src/matcher/definition.lua | 6 | ||||
-rw-r--r-- | server/src/matcher/implementation.lua | 10 |
2 files changed, 11 insertions, 5 deletions
diff --git a/server/src/matcher/definition.lua b/server/src/matcher/definition.lua index 5b79aedd..3ca27b89 100644 --- a/server/src/matcher/definition.lua +++ b/server/src/matcher/definition.lua @@ -2,7 +2,7 @@ local function parseResultAcrossUri(positions, vm, result) -- 跨越文件时,遍历的是值的绑定信息 for _, info in ipairs(result.value) do if info.type == 'set' and info.source.uri == result.value.uri then - positions[#positions+1] = { + positions[1] = { info.source.start, info.source.finish, info.source.uri, @@ -12,7 +12,7 @@ local function parseResultAcrossUri(positions, vm, result) if #positions == 0 then for _, info in ipairs(result.value) do if info.type == 'return' and info.source.uri == result.value.uri then - positions[#positions+1] = { + positions[1] = { info.source.start, info.source.finish, info.source.uri, @@ -21,7 +21,7 @@ local function parseResultAcrossUri(positions, vm, result) end end if #positions == 0 then - positions[#positions+1] = { + positions[1] = { 0, 0, result.value.uri, } diff --git a/server/src/matcher/implementation.lua b/server/src/matcher/implementation.lua index 6f90484e..9ff3fdca 100644 --- a/server/src/matcher/implementation.lua +++ b/server/src/matcher/implementation.lua @@ -2,7 +2,7 @@ local function parseResultAcrossUri(positions, vm, result) -- 跨越文件时,遍历的是值的绑定信息 for _, info in ipairs(result.value) do if info.type == 'set' and info.source.uri == result.value.uri then - positions[#positions+1] = { + positions[1] = { info.source.start, info.source.finish, info.source.uri, @@ -12,7 +12,7 @@ local function parseResultAcrossUri(positions, vm, result) if #positions == 0 then for _, info in ipairs(result.value) do if info.type == 'return' and info.source.uri == result.value.uri then - positions[#positions+1] = { + positions[1] = { info.source.start, info.source.finish, info.source.uri, @@ -20,6 +20,12 @@ local function parseResultAcrossUri(positions, vm, result) end end end + if #positions == 0 then + positions[1] = { + 0, 0, + result.value.uri, + } + end end local function parseResult(vm, result) |