diff options
Diffstat (limited to 'script-beta')
-rw-r--r-- | script-beta/core/completion.lua | 4 | ||||
-rw-r--r-- | script-beta/parser/guide.lua | 3 | ||||
-rw-r--r-- | script-beta/provider/init.lua | 5 |
3 files changed, 8 insertions, 4 deletions
diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua index 0532f1be..35e4e21f 100644 --- a/script-beta/core/completion.lua +++ b/script-beta/core/completion.lua @@ -85,18 +85,20 @@ local function checkField(ast, text, word, offset, results) return end end + local used = {} vm.eachField(parent, function (info) local key = info.key if key and key:sub(1, 1) == 's' and info.source.finish ~= offset then local name = key:sub(3) - if matchKey(word, name) then + if not used[name] and matchKey(word, name) then results[#results+1] = { label = name, kind = ckind.Field, } end + used[name] = true end end) end diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua index 4ccfd23d..b4b45d0b 100644 --- a/script-beta/parser/guide.lua +++ b/script-beta/parser/guide.lua @@ -259,9 +259,6 @@ function m.getVisibleLocalNames(block, pos, callback) callback(name) end end - if res then - return res, res - end ::CONTINUE:: block = m.getParentBlock(block) end diff --git a/script-beta/provider/init.lua b/script-beta/provider/init.lua index 8fda0315..6faae12e 100644 --- a/script-beta/provider/init.lua +++ b/script-beta/provider/init.lua @@ -300,10 +300,15 @@ proto.on('textDocument/completion', function (params) if not files.exists(uri) then return nil end + local clock = os.clock() local lines = files.getLines(uri) local text = files.getText(uri) local offset = define.offset(lines, text, params.position) local result = core(uri, offset) + local passed = os.clock() - clock + if passed > 0.1 then + log.warn(('Completion takes %.3f sec.'):format(passed)) + end if not result then return nil end |