diff --git a/changelog.md b/changelog.md index 9eee1e47f..57110d705 100644 --- a/changelog.md +++ b/changelog.md @@ -11,6 +11,7 @@ * `FIX` completion: may insert error text when continuous inputing * `FIX` completion: may insert error text after resolve * `FIX` [#349](https://github.com/sumneko/lua-language-server/issues/349) +* `FIX` [#396](https://github.com/sumneko/lua-language-server/issues/396) ## 1.15.1 `2021-2-18` diff --git a/script/parser/guide.lua b/script/parser/guide.lua index 050dcb4d6..377b1ce86 100644 --- a/script/parser/guide.lua +++ b/script/parser/guide.lua @@ -2403,12 +2403,17 @@ function m.checkSameSimpleAsKeyOrValueInForParis(status, ref, start, pushQueue) end local function hasTypeName(doc, name) - if doc.type ~= 'doc.type' then - return false + if doc.type == 'doc.type' then + for _, tunit in ipairs(doc.types) do + if tunit.type == 'doc.type.name' + and tunit[1] == name then + return true + end + end end - for _, tunit in ipairs(doc.types) do - if tunit.type == 'doc.type.name' - and tunit[1] == name then + if doc.type == 'doc.type.name' + or doc.type == 'doc.class.name' then + if doc[1] == name then return true end end @@ -2421,9 +2426,6 @@ function m.checkSameSimpleInString(status, ref, start, pushQueue, mode) and not hasTypeName(ref, 'string') then return end - if status.depth > 5 then - return - end if not status.interface.docType then return end diff --git a/test/completion/init.lua b/test/completion/init.lua index 011026322..a44b4a08f 100644 --- a/test/completion/init.lua +++ b/test/completion/init.lua @@ -2051,3 +2051,13 @@ f({ kind = define.CompletionItemKind.Property, }, } + +TEST [[ +---@return string +local function f() end + +local s = f() + +s.$ +]] +(EXISTS)