diff options
Diffstat (limited to 'server/src/core')
-rw-r--r-- | server/src/core/completion.lua | 14 | ||||
-rw-r--r-- | server/src/core/find_result.lua | 8 |
2 files changed, 18 insertions, 4 deletions
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, |