diff options
-rw-r--r-- | server/src/matcher/completion.lua | 19 | ||||
-rw-r--r-- | server/src/matcher/vm.lua | 2 | ||||
-rw-r--r-- | server/test/completion/init.lua | 2 |
3 files changed, 22 insertions, 1 deletions
diff --git a/server/src/matcher/completion.lua b/server/src/matcher/completion.lua index 5d651034..d75efab4 100644 --- a/server/src/matcher/completion.lua +++ b/server/src/matcher/completion.lua @@ -261,6 +261,22 @@ local function findClosePos(vm, pos) return nil end +local function isContainPos(obj, pos) + if obj.start <= pos and obj.finish + 1 >= pos then + return true + end + return false +end + +local function isInString(vm, pos) + for _, source in ipairs(vm.results.strings) do + if isContainPos(source, pos) then + return true + end + end + return false +end + return function (vm, pos) local result, source = findResult(vm, pos) if not result then @@ -268,6 +284,9 @@ return function (vm, pos) if not result then return nil end + if isInString(vm, pos) then + return nil + end end local list = {} diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua index 23a74c7f..48a8a49c 100644 --- a/server/src/matcher/vm.lua +++ b/server/src/matcher/vm.lua @@ -968,6 +968,7 @@ function mt:getExp(exp) if tp == 'nil' then return self:createValue('nil', exp) elseif tp == 'string' then + self.results.strings[#self.results.strings+1] = exp return self:createValue('string', exp, exp[1]) elseif tp == 'boolean' then return self:createValue('boolean', exp, exp[1]) @@ -1364,6 +1365,7 @@ local function compile(ast, lsp, uri) funcs = {}, calls = {}, sources= {}, + strings= {}, main = nil, }, libraryValue = {}, diff --git a/server/test/completion/init.lua b/server/test/completion/init.lua index 96a12032..face4216 100644 --- a/server/test/completion/init.lua +++ b/server/test/completion/init.lua @@ -266,4 +266,4 @@ TEST [[ ]] (EXISTS) ---TEST 'local s = "a:@"' (nil) TODO +TEST 'local s = "a:@"' (nil) |