diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-11-19 15:10:07 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-11-19 15:10:07 +0800 |
commit | 2c07a7a12bf840e1a90abc117fd5e69866f76fdb (patch) | |
tree | e3283b21e345a5d6a3fa062bd1ccb5503888b61f /script-beta/core | |
parent | a1c4ebfb23152e23bf556811aad39bf917c5cb60 (diff) | |
download | lua-language-server-2c07a7a12bf840e1a90abc117fd5e69866f76fdb.zip |
自动完成和全局变量相关的一些bug
Diffstat (limited to 'script-beta/core')
-rw-r--r-- | script-beta/core/completion.lua | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua index 479d6ab4..610279db 100644 --- a/script-beta/core/completion.lua +++ b/script-beta/core/completion.lua @@ -425,6 +425,9 @@ local function checkFieldOfRefs(refs, ast, word, start, offset, parent, oop, res if isSameSource(ast, src, start) then -- 由于fastGlobal的优化,全局变量只会找出一个值,有可能找出自己 -- 所以遇到自己的时候重新找一下有没有其他定义 + if not guide.isGlobal(src) then + goto CONTINUE + end if #vm.getGlobals(key) <= 1 then goto CONTINUE end @@ -438,14 +441,19 @@ local function checkFieldOfRefs(refs, ast, word, start, offset, parent, oop, res end local last = fields[name] if not last then - fields[name] = src + if guide.isGlobal(src) then + fields[name] = vm.getDefs(src, 'deep')[1] or src + else + fields[name] = src + end goto CONTINUE end if src.type == 'tablefield' or src.type == 'setfield' or src.type == 'tableindex' or src.type == 'setindex' - or src.type == 'setmethod' then + or src.type == 'setmethod' + or src.type == 'setglobal' then fields[name] = src goto CONTINUE end |