From e8158fd4de7e076ef019493afa33b9c2820de75a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 18 Mar 2019 17:54:30 +0800 Subject: =?UTF-8?q?=E9=99=8D=E4=BD=8E=E6=96=87=E4=BB=B6=E7=AC=A6=E5=8F=B7?= =?UTF-8?q?=E7=9A=84=E4=BC=98=E5=85=88=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/method/textDocument/documentSymbol.lua | 25 +++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'server/src/method/textDocument') 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 -- cgit v1.2.3