From 88b9936cfef9f84580cae3ba2f346c95f8f27103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 26 Mar 2019 14:57:15 +0800 Subject: =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=BC=95=E7=94=A8=E9=93=BE=E4=B8=8D?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/method/textDocument/documentSymbol.lua | 2 +- server/src/method/textDocument/references.lua | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'server/src/method/textDocument') 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 -- cgit v1.2.3