Skip to content
Snippets Groups Projects
Commit 674892ab authored by 最萌小汐's avatar 最萌小汐
Browse files

先保证自动完成的速度

parent 67eae45b
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ local fs = require 'bee.filesystem' ...@@ -5,7 +5,7 @@ local fs = require 'bee.filesystem'
ROOT = fs.path(rootPath) ROOT = fs.path(rootPath)
LANG = LANG or 'en-US' LANG = LANG or 'en-US'
collectgarbage('generational', 10, 50) --collectgarbage('generational', 10, 50)
--collectgarbage('incremental', 120, 120, 0) --collectgarbage('incremental', 120, 120, 0)
log = require 'log' log = require 'log'
......
...@@ -13,6 +13,7 @@ local config = require 'config' ...@@ -13,6 +13,7 @@ local config = require 'config'
local util = require 'utility' local util = require 'utility'
local markdown = require 'provider.markdown' local markdown = require 'provider.markdown'
local findSource = require 'core.find-source' local findSource = require 'core.find-source'
local await = require 'await'
local stackID = 0 local stackID = 0
local stacks = {} local stacks = {}
...@@ -234,8 +235,8 @@ local function checkFieldThen(src, used, word, start, parent, oop, results) ...@@ -234,8 +235,8 @@ local function checkFieldThen(src, used, word, start, parent, oop, results)
if used[name] then if used[name] then
return return
end end
if not matchKey(word, name) then
used[name] = true used[name] = true
if not matchKey(word, name) then
return return
end end
local kind = ckind.Field local kind = ckind.Field
...@@ -245,7 +246,6 @@ local function checkFieldThen(src, used, word, start, parent, oop, results) ...@@ -245,7 +246,6 @@ local function checkFieldThen(src, used, word, start, parent, oop, results)
else else
kind = ckind.Function kind = ckind.Function
end end
used[name] = true
buildFunction(results, src, oop, { buildFunction(results, src, oop, {
label = name, label = name,
kind = kind, kind = kind,
...@@ -260,7 +260,6 @@ local function checkFieldThen(src, used, word, start, parent, oop, results) ...@@ -260,7 +260,6 @@ local function checkFieldThen(src, used, word, start, parent, oop, results)
if oop then if oop then
return return
end end
used[name] = true
local literal = vm.getLiteral(src) local literal = vm.getLiteral(src)
if literal ~= nil then if literal ~= nil then
kind = ckind.Enum kind = ckind.Enum
......
...@@ -212,13 +212,16 @@ end ...@@ -212,13 +212,16 @@ end
function m.start() function m.start()
m._start = true m._start = true
m.diagnosticsAll() --m.diagnosticsAll()
end end
files.watch(function (env, uri) files.watch(function (env, uri)
if env == 'remove' then if env == 'remove' then
m.clear(uri) m.clear(uri)
elseif env == 'update' then elseif env == 'update' then
if not m._start then
return
end
await.create(function () await.create(function ()
await.delay(function () await.delay(function ()
return files.globalVersion return files.globalVersion
......
...@@ -319,7 +319,7 @@ proto.on('textDocument/completion', function (params) ...@@ -319,7 +319,7 @@ proto.on('textDocument/completion', function (params)
if not result then if not result then
return nil return nil
end end
local easy = true local easy = false
local items = {} local items = {}
for i, res in ipairs(result) do for i, res in ipairs(result) do
local item = { local item = {
...@@ -332,11 +332,13 @@ proto.on('textDocument/completion', function (params) ...@@ -332,11 +332,13 @@ proto.on('textDocument/completion', function (params)
if res.id then if res.id then
if easy and os.clock() - clock < 0.05 then if easy and os.clock() - clock < 0.05 then
local resolved = core.resolve(res.id) local resolved = core.resolve(res.id)
if resolved then
item.detail = resolved.detail item.detail = resolved.detail
item.documentation = resolved.description and { item.documentation = resolved.description and {
value = resolved.description, value = resolved.description,
kind = 'markdown', kind = 'markdown',
} }
end
else else
easy = false easy = false
item.data = { item.data = {
...@@ -362,6 +364,9 @@ proto.on('completionItem/resolve', function (item) ...@@ -362,6 +364,9 @@ proto.on('completionItem/resolve', function (item)
end end
await.setPriority(1000) await.setPriority(1000)
local resolved = core.resolve(id) local resolved = core.resolve(id)
if not resolved then
return nil
end
item.detail = resolved.detail item.detail = resolved.detail
item.documentation = resolved.description and { item.documentation = resolved.description and {
value = resolved.description, value = resolved.description,
......
...@@ -2,7 +2,7 @@ local vm = require 'vm.vm' ...@@ -2,7 +2,7 @@ local vm = require 'vm.vm'
local guide = require 'parser.guide' local guide = require 'parser.guide'
local util = require 'utility' local util = require 'utility'
local function eachRef(source, results) local function getRefs(source, results)
results = results or {} results = results or {}
local lock = vm.lock('eachDef', source) local lock = vm.lock('eachDef', source)
if not lock then if not lock then
...@@ -22,8 +22,8 @@ local function eachRef(source, results) ...@@ -22,8 +22,8 @@ local function eachRef(source, results)
end end
function vm.getRefs(source) function vm.getRefs(source)
local cache = vm.getCache('eachRef')[source] or eachRef(source) local cache = vm.getCache('eachRef')[source] or getRefs(source)
vm.getCache('eachDef')[source] = cache vm.getCache('eachRef')[source] = cache
return cache return cache
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment