From 050dcbe14a6e2d6ca267193119b016d1432d121b Mon Sep 17 00:00:00 2001 From: sumneko Date: Thu, 30 May 2019 10:27:14 +0800 Subject: =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=AF=B9toclose=E7=9A=84=E7=89=B9?= =?UTF-8?q?=E6=AE=8A=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/core/completion.lua | 39 ++++++--------------------------------- 1 file changed, 6 insertions(+), 33 deletions(-) (limited to 'server/src/core/completion.lua') diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua index 331eb6cc..a938d83c 100644 --- a/server/src/core/completion.lua +++ b/server/src/core/completion.lua @@ -373,19 +373,16 @@ end local function searchAsLocal(vm, source, word, callback) local loc = source:bindLocal() - if loc then - local close = loc:close() - -- 因为闭包的关系落在局部变量finish到close范围内的全局变量一定能访问到该局部变量 - searchCloseGlobal(vm, source.finish, close, word, callback) + if not loc then + return end + local close = loc:close() + -- 因为闭包的关系落在局部变量finish到close范围内的全局变量一定能访问到该局部变量 + searchCloseGlobal(vm, source.finish, close, word, callback) -- 特殊支持 local function if matchKey(word, 'function') then callback('function', nil, CompletionItemKind.Keyword) end - -- 特殊支持 local *toclose - if word == '' and config.config.runtime.version == 'Lua 5.4' then - callback('*toclose', nil, CompletionItemKind.Keyword) - end end local function searchAsArg(vm, source, word, callback) @@ -846,27 +843,6 @@ local function makeList(source, pos, word) end, list end -local function searchToclose(text, source, word, callback) - local pos = source.start - if text:sub(pos-1, pos-1) ~= '*' then - return false - end - if not matchKey(word, 'toclose') then - return false - end - for i = pos-1, 1, -1 do - if text:sub(i, i):match '[^%s%c]' then - if text:sub(i - #'local' + 1, i) == 'local' then - callback('toclose', nil, CompletionItemKind.Keyword) - return true - else - return false - end - end - end - return false -end - local function keywordSource(vm, word, pos) if not KEYMAP[word] then return nil @@ -933,7 +909,7 @@ local function getSource(vm, pos, text, filter) return source, pos, word end pos = findStartPos(pos, text) - source = findSource(vm, pos, filter) + source = findSource(vm, pos, filter) or findSource(vm, pos-1, filter) return source, pos, word end @@ -961,9 +937,6 @@ return function (vm, text, pos, oldText) end State = {} local callback, list = makeList(source, pos, word) - if searchToclose(text, source, word, callback) then - return list - end searchSpecial(vm, source, word, callback, pos, text) searchCallArg(vm, source, word, callback, pos) searchSource(vm, source, word, callback, pos) -- cgit v1.2.3