diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-03-18 17:54:30 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-03-18 17:54:30 +0800 |
commit | e8158fd4de7e076ef019493afa33b9c2820de75a (patch) | |
tree | b48cf97556b4bcafdae14119680220be704f94c7 /server/src/method/textDocument | |
parent | 5da8740d528b6f20e969a5b2f5fbd7679e3d267d (diff) | |
download | lua-language-server-e8158fd4de7e076ef019493afa33b9c2820de75a.zip |
降低文件符号的优先度
Diffstat (limited to 'server/src/method/textDocument')
-rw-r--r-- | server/src/method/textDocument/documentSymbol.lua | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/server/src/method/textDocument/documentSymbol.lua b/server/src/method/textDocument/documentSymbol.lua index 9b21131d..4e7c3808 100644 --- a/server/src/method/textDocument/documentSymbol.lua +++ b/server/src/method/textDocument/documentSymbol.lua @@ -46,17 +46,30 @@ return function (lsp, params) end return function (response) - timerCache[uri] = ac.wait(0.5, function () - local symbols = core.documentSymbol(vm) - if not symbols then - return nil + local co = coroutine.create(function () + return core.documentSymbol(vm) + end) + timerCache[uri] = ac.loop(0.001, function (t) + local suc, res = coroutine.resume(co) + if not suc then + t:remove() + error(res) + return + end + if coroutine.status(co) == 'suspended' then + return + end + + t:remove() + if not res then + response(nil) end - for _, symbol in ipairs(symbols) do + for _, symbol in ipairs(res) do convertRange(lines, symbol) end - response(symbols) + response(res) end) end end |