diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-21 18:40:29 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-21 18:40:29 +0800 |
commit | 3b17bd6cb09034b74405301c53782cee6e91a2f2 (patch) | |
tree | cf21aaf15f53572deb2b788c3f600e0d75f1853f /server | |
parent | 8de0c9246ada8f823f6abb1edde38c5768af19fa (diff) | |
download | lua-language-server-3b17bd6cb09034b74405301c53782cee6e91a2f2.zip |
字符串中屏蔽自动完成
Diffstat (limited to 'server')
-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) |