From 674892abc53ad6752326135c8aaf60073f80b632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Sat, 15 Aug 2020 18:57:58 +0800 Subject: =?UTF-8?q?=E5=85=88=E4=BF=9D=E8=AF=81=E8=87=AA=E5=8A=A8=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E7=9A=84=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-beta/core/completion.lua | 5 ++--- script-beta/provider/diagnostic.lua | 5 ++++- script-beta/provider/provider.lua | 17 +++++++++++------ script-beta/vm/eachRef.lua | 6 +++--- 4 files changed, 20 insertions(+), 13 deletions(-) (limited to 'script-beta') diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua index ba4119fb..5f7e153e 100644 --- a/script-beta/core/completion.lua +++ b/script-beta/core/completion.lua @@ -13,6 +13,7 @@ local config = require 'config' local util = require 'utility' local markdown = require 'provider.markdown' local findSource = require 'core.find-source' +local await = require 'await' local stackID = 0 local stacks = {} @@ -234,8 +235,8 @@ local function checkFieldThen(src, used, word, start, parent, oop, results) if used[name] then return end + used[name] = true if not matchKey(word, name) then - used[name] = true return end local kind = ckind.Field @@ -245,7 +246,6 @@ local function checkFieldThen(src, used, word, start, parent, oop, results) else kind = ckind.Function end - used[name] = true buildFunction(results, src, oop, { label = name, kind = kind, @@ -260,7 +260,6 @@ local function checkFieldThen(src, used, word, start, parent, oop, results) if oop then return end - used[name] = true local literal = vm.getLiteral(src) if literal ~= nil then kind = ckind.Enum diff --git a/script-beta/provider/diagnostic.lua b/script-beta/provider/diagnostic.lua index 92aa01c2..28f0cf8e 100644 --- a/script-beta/provider/diagnostic.lua +++ b/script-beta/provider/diagnostic.lua @@ -212,13 +212,16 @@ end function m.start() m._start = true - m.diagnosticsAll() + --m.diagnosticsAll() end files.watch(function (env, uri) if env == 'remove' then m.clear(uri) elseif env == 'update' then + if not m._start then + return + end await.create(function () await.delay(function () return files.globalVersion diff --git a/script-beta/provider/provider.lua b/script-beta/provider/provider.lua index aa649370..ba635255 100644 --- a/script-beta/provider/provider.lua +++ b/script-beta/provider/provider.lua @@ -319,7 +319,7 @@ proto.on('textDocument/completion', function (params) if not result then return nil end - local easy = true + local easy = false local items = {} for i, res in ipairs(result) do local item = { @@ -332,11 +332,13 @@ proto.on('textDocument/completion', function (params) if res.id then if easy and os.clock() - clock < 0.05 then local resolved = core.resolve(res.id) - item.detail = resolved.detail - item.documentation = resolved.description and { - value = resolved.description, - kind = 'markdown', - } + if resolved then + item.detail = resolved.detail + item.documentation = resolved.description and { + value = resolved.description, + kind = 'markdown', + } + end else easy = false item.data = { @@ -362,6 +364,9 @@ proto.on('completionItem/resolve', function (item) end await.setPriority(1000) local resolved = core.resolve(id) + if not resolved then + return nil + end item.detail = resolved.detail item.documentation = resolved.description and { value = resolved.description, diff --git a/script-beta/vm/eachRef.lua b/script-beta/vm/eachRef.lua index 65ce4d05..d372b03b 100644 --- a/script-beta/vm/eachRef.lua +++ b/script-beta/vm/eachRef.lua @@ -2,7 +2,7 @@ local vm = require 'vm.vm' local guide = require 'parser.guide' local util = require 'utility' -local function eachRef(source, results) +local function getRefs(source, results) results = results or {} local lock = vm.lock('eachDef', source) if not lock then @@ -22,8 +22,8 @@ local function eachRef(source, results) end function vm.getRefs(source) - local cache = vm.getCache('eachRef')[source] or eachRef(source) - vm.getCache('eachDef')[source] = cache + local cache = vm.getCache('eachRef')[source] or getRefs(source) + vm.getCache('eachRef')[source] = cache return cache end -- cgit v1.2.3