diff options
-rw-r--r-- | changelog.md | 1 | ||||
-rw-r--r-- | script/core/completion.lua | 14 | ||||
-rw-r--r-- | script/parser/guide.lua | 5 | ||||
-rw-r--r-- | test/completion/init.lua | 13 |
4 files changed, 25 insertions, 8 deletions
diff --git a/changelog.md b/changelog.md index cd4ce15e..2e0e366b 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,7 @@ ## 2.3.3 * `NEW` config supports prop * `FIX` [#612](https://github.com/sumneko/lua-language-server/issues/612) +* `FIX` [#613](https://github.com/sumneko/lua-language-server/issues/613) ## 2.3.2 `2021-7-21` diff --git a/script/core/completion.lua b/script/core/completion.lua index dda47f4c..d5cca4e0 100644 --- a/script/core/completion.lua +++ b/script/core/completion.lua @@ -512,6 +512,7 @@ end local function checkFieldOfRefs(refs, ast, word, start, offset, parent, oop, results, locals, isGlobal) local fields = {} + local funcs = {} local count = 0 for _, src in ipairs(refs) do local name = vm.getKeyName(src) @@ -543,11 +544,15 @@ local function checkFieldOfRefs(refs, ast, word, start, offset, parent, oop, res end end end + funcs[name] = true + if fields[name] and not guide.isSet(fields[name]) then + fields[name] = nil + end goto CONTINUE end end local last = fields[name] - if last == nil then + if last == nil and not funcs[name] then fields[name] = src count = count + 1 goto CONTINUE @@ -555,12 +560,7 @@ local function checkFieldOfRefs(refs, ast, word, start, offset, parent, oop, res if vm.isDeprecated(src) then goto CONTINUE end - if src.type == 'tablefield' - or src.type == 'setfield' - or src.type == 'tableindex' - or src.type == 'setindex' - or src.type == 'setmethod' - or src.type == 'setglobal' then + if guide.isSet(src) then fields[name] = src goto CONTINUE end diff --git a/script/parser/guide.lua b/script/parser/guide.lua index 725d4e1a..9e854bf5 100644 --- a/script/parser/guide.lua +++ b/script/parser/guide.lua @@ -782,7 +782,10 @@ function m.isSet(source) or tp == 'setindex' or tp == 'tablefield' or tp == 'tableindex' - or tp == 'tableexp' then + or tp == 'tableexp' + or tp == 'doc.field.name' + or tp == 'doc.field' + or tp == 'doc.type.field' then return true end if tp == 'call' then diff --git a/test/completion/init.lua b/test/completion/init.lua index 9540eb2a..d975fa7e 100644 --- a/test/completion/init.lua +++ b/test/completion/init.lua @@ -2755,3 +2755,16 @@ local c c:on('$') ]] (EXISTS) + +TEST [[ +local m = {} + +function m.f() +end + +m.f() +m.$ +]] +{ + [1] = EXISTS, +} |