diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-03-26 14:57:15 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-03-26 14:57:15 +0800 |
commit | 88b9936cfef9f84580cae3ba2f346c95f8f27103 (patch) | |
tree | 15b009745422b6d5654a029063f8dd7d84080b5c /server/src | |
parent | 6d929d7682fd297f49773efef5be039f2831427a (diff) | |
download | lua-language-server-88b9936cfef9f84580cae3ba2f346c95f8f27103.zip |
修正引用链不正确的问题
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/method/textDocument/documentSymbol.lua | 2 | ||||
-rw-r--r-- | server/src/method/textDocument/references.lua | 9 | ||||
-rw-r--r-- | server/src/service.lua | 17 | ||||
-rw-r--r-- | server/src/vm/vm.lua | 1 |
4 files changed, 17 insertions, 12 deletions
diff --git a/server/src/method/textDocument/documentSymbol.lua b/server/src/method/textDocument/documentSymbol.lua index f9823385..321baae3 100644 --- a/server/src/method/textDocument/documentSymbol.lua +++ b/server/src/method/textDocument/documentSymbol.lua @@ -41,7 +41,7 @@ return function (lsp, params) end return function (response) - timerCache[uri] = ac.loop(0.1, function (t) + timerCache[uri] = ac.timer(0.1, 10, function (t) local vm, lines = lsp:getVM(uri) if not vm then return diff --git a/server/src/method/textDocument/references.lua b/server/src/method/textDocument/references.lua index 7dbd4b95..ad1ebce0 100644 --- a/server/src/method/textDocument/references.lua +++ b/server/src/method/textDocument/references.lua @@ -1,4 +1,5 @@ local core = require 'core' +local LastTask return function (lsp, params) local uri = params.textDocument.uri @@ -8,15 +9,21 @@ return function (lsp, params) return nil end + if LastTask then + LastTask:remove() + LastTask = nil + end + -- lua是从1开始的,因此都要+1 local position = lines:positionAsChar(params.position.line + 1, params.position.character) return function (response) - ac.timer(0.1, 100, function (t) + LastTask = ac.timer(0.1, 100, function (t) if lsp:isWaitingCompile() then return end t:remove() + vm, lines = lsp:getVM(uri) local positions = core.references(vm, position, declarat) if not positions then diff --git a/server/src/service.lua b/server/src/service.lua index 7f22732e..78be0d0c 100644 --- a/server/src/service.lua +++ b/server/src/service.lua @@ -317,19 +317,18 @@ function mt:_clearChainNode(obj, uri) end function mt:_compileChain(obj, compiled) - if not obj.child then - return - end if not compiled then compiled = {} end - local list = {} - for child in pairs(obj.child) do - list[#list+1] = child + if obj.child then + for uri in pairs(obj.child) do + self:needCompile(uri, compiled) + end end - table.sort(list) - for _, child in ipairs(list) do - self:needCompile(child, compiled) + if obj.parent then + for uri in pairs(obj.parent) do + self:needCompile(uri, compiled) + end end end diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua index 5774711c..c519ad72 100644 --- a/server/src/vm/vm.lua +++ b/server/src/vm/vm.lua @@ -1180,7 +1180,6 @@ local function compile(ast, lsp, uri) local vm = setmetatable({ funcs = {}, sources = {}, - require = {}, main = nil, env = nil, lsp = lsp, |