From ed21959eea02f2479ec87b6798d38b368542d881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 21 Jan 2019 17:18:18 +0800 Subject: =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=87=AA=E5=8A=A8=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E7=9A=84=E4=B8=80=E4=B8=AAbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/core/completion.lua | 14 ++++++++++++-- server/src/core/find_result.lua | 8 ++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) (limited to 'server/src') diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua index 13a36d94..6c49fbb0 100644 --- a/server/src/core/completion.lua +++ b/server/src/core/completion.lua @@ -547,6 +547,16 @@ local function clearList(list, source) end end +local function isValidResult(result) + if not result then + return false + end + if result.type == 'local' or result.type == 'field' then + return true + end + return false +end + return function (vm, pos, word) local list = {} local callback = makeList(list) @@ -558,10 +568,10 @@ return function (vm, pos, word) searchSpecial(vm, pos, callback) if not inString then local result, source = findResult(vm, pos) - if not result then + if not isValidResult(result) then result, source = findClosePos(vm, pos) end - if result then + if isValidResult(result) then callback = makeList(list, source) searchInResult(result, source, vm, pos, callback) searchAllWords(result.key, vm, callback) diff --git a/server/src/core/find_result.lua b/server/src/core/find_result.lua index ac8dc3f4..e4074879 100644 --- a/server/src/core/find_result.lua +++ b/server/src/core/find_result.lua @@ -5,12 +5,16 @@ local function isContainPos(obj, pos) return false end +local function isValidSource(source) + return source.type ~= 'simple' +end + local function findAtPos(results, pos, level) local res = {} for sources, object in pairs(results.sources) do if sources.type == 'multi-source' then for _, source in ipairs(sources) do - if source.type ~= 'simple' and isContainPos(source, pos) then + if isValidSource(source) and isContainPos(source, pos) then res[#res+1] = { object = object, source = source, @@ -20,7 +24,7 @@ local function findAtPos(results, pos, level) end else local source = sources - if source.type ~= 'simple' and isContainPos(source, pos) then + if isValidSource(source) and isContainPos(source, pos) then res[#res+1] = { object = object, source = source, -- cgit v1.2.3