diff options
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/method/textDocument/documentSymbol.lua | 28 | ||||
-rw-r--r-- | server/src/service.lua | 9 |
2 files changed, 14 insertions, 23 deletions
diff --git a/server/src/method/textDocument/documentSymbol.lua b/server/src/method/textDocument/documentSymbol.lua index 4e7c3808..f9823385 100644 --- a/server/src/method/textDocument/documentSymbol.lua +++ b/server/src/method/textDocument/documentSymbol.lua @@ -40,36 +40,26 @@ return function (lsp, params) timerCache[uri] = nil end - local vm, lines = lsp:loadVM(uri) - if not vm then - return nil - end - return function (response) - 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 + timerCache[uri] = ac.loop(0.1, function (t) + local vm, lines = lsp:getVM(uri) + if not vm then return end t:remove() - if not res then + + local symbols = core.documentSymbol(vm) + if not symbols then response(nil) + return end - for _, symbol in ipairs(res) do + for _, symbol in ipairs(symbols) do convertRange(lines, symbol) end - response(res) + response(symbols) end) end end diff --git a/server/src/service.lua b/server/src/service.lua index 0ec563e8..2026bfa9 100644 --- a/server/src/service.lua +++ b/server/src/service.lua @@ -484,10 +484,11 @@ function mt:_createCompileTask() local uri = self._needCompile[1] if uri then self:compileVM(uri) - end - uri = next(self._needDiagnostics) - if uri then - self:doDiagnostics(uri) + else + uri = next(self._needDiagnostics) + if uri then + self:doDiagnostics(uri) + end end end) end |